gl-setup: dash-compat
before someone runs it on the new Ubuntu :)
This commit is contained in:
parent
b537a4acd4
commit
f282b8f926
18
src/gl-setup
18
src/gl-setup
|
@ -19,23 +19,23 @@ GL_PACKAGE_CONF=/tmp/share/gitolite/conf
|
||||||
# pubkey file if you happen to have lost all gitolite-access to the repos (but
|
# pubkey file if you happen to have lost all gitolite-access to the repos (but
|
||||||
# do have shell access via some other means)
|
# do have shell access via some other means)
|
||||||
|
|
||||||
die() { echo "$@"; echo death at line number ${BASH_LINENO[0]}; exit 1; }
|
die() { echo "$@"; exit 1; }
|
||||||
|
|
||||||
pubkey_file=$1
|
pubkey_file=$1
|
||||||
admin_name=
|
admin_name=
|
||||||
if [[ -n $pubkey_file ]]
|
if [ -n "$pubkey_file" ]
|
||||||
then
|
then
|
||||||
[[ $pubkey_file =~ .pub$ ]] || die "$pubkey_file must end in .pub"
|
echo $pubkey_file | grep '.pub$' >/dev/null || die "$pubkey_file must end in .pub"
|
||||||
[[ -f $pubkey_file ]] || die "cant find $pubkey_file"
|
[ -f $pubkey_file ] || die "cant find $pubkey_file"
|
||||||
admin_name=$(basename $pubkey_file .pub)
|
admin_name=$(basename $pubkey_file .pub)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f ~/.gitolite.rc ]]
|
if [ -f ~/.gitolite.rc ]
|
||||||
then
|
then
|
||||||
perl -ne 's/^\s+//; s/[\s=].*//; print if /^\$/;' < $GL_PACKAGE_CONF/example.gitolite.rc | sort > .newvars
|
perl -ne 's/^\s+//; s/[\s=].*//; print if /^\$/;' < $GL_PACKAGE_CONF/example.gitolite.rc | sort > .newvars
|
||||||
perl -ne 's/^\s+//; s/[\s=].*//; print if /^\$/;' < ~/.gitolite.rc | sort > .oldvars
|
perl -ne 's/^\s+//; s/[\s=].*//; print if /^\$/;' < ~/.gitolite.rc | sort > .oldvars
|
||||||
comm -23 .newvars .oldvars > .diffvars
|
comm -23 .newvars .oldvars > .diffvars
|
||||||
if [[ -s .diffvars ]]
|
if [ -s .diffvars ]
|
||||||
then
|
then
|
||||||
cp $GL_PACKAGE_CONF/example.gitolite.rc ~/.gitolite.rc.new
|
cp $GL_PACKAGE_CONF/example.gitolite.rc ~/.gitolite.rc.new
|
||||||
echo new version of the rc file saved in ~/.gitolite.rc.new
|
echo new version of the rc file saved in ~/.gitolite.rc.new
|
||||||
|
@ -48,7 +48,7 @@ then
|
||||||
fi
|
fi
|
||||||
rm -f .newvars .oldvars .diffvars
|
rm -f .newvars .oldvars .diffvars
|
||||||
else
|
else
|
||||||
[[ -n $pubkey_file ]] || die "looks like first run -- I need a pubkey file"
|
[ -n "$pubkey_file" ] || die "looks like first run -- I need a pubkey file"
|
||||||
cp $GL_PACKAGE_CONF/example.gitolite.rc ~/.gitolite.rc
|
cp $GL_PACKAGE_CONF/example.gitolite.rc ~/.gitolite.rc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ gl-install -q
|
||||||
GL_ADMINDIR=$(cd;perl -e 'do ".gitolite.rc"; print $GL_ADMINDIR')
|
GL_ADMINDIR=$(cd;perl -e 'do ".gitolite.rc"; print $GL_ADMINDIR')
|
||||||
REPO_BASE=$( cd;perl -e 'do ".gitolite.rc"; print $REPO_BASE' )
|
REPO_BASE=$( cd;perl -e 'do ".gitolite.rc"; print $REPO_BASE' )
|
||||||
|
|
||||||
[[ -f $GL_ADMINDIR/conf/gitolite.conf ]] || {
|
[ -f $GL_ADMINDIR/conf/gitolite.conf ] || {
|
||||||
cat <<EOF > $GL_ADMINDIR/conf/gitolite.conf
|
cat <<EOF > $GL_ADMINDIR/conf/gitolite.conf
|
||||||
repo gitolite-admin
|
repo gitolite-admin
|
||||||
RW+ = $admin_name
|
RW+ = $admin_name
|
||||||
|
@ -75,7 +75,7 @@ REPO_BASE=$( cd;perl -e 'do ".gitolite.rc"; print $REPO_BASE' )
|
||||||
RW+ = @all
|
RW+ = @all
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
[[ -n $pubkey_file ]] && cp $pubkey_file $GL_ADMINDIR/keydir
|
[ -n "$pubkey_file" ] && cp $pubkey_file $GL_ADMINDIR/keydir
|
||||||
|
|
||||||
touch $HOME/.ssh/authorized_keys
|
touch $HOME/.ssh/authorized_keys
|
||||||
gl-compile-conf -q
|
gl-compile-conf -q
|
||||||
|
|
Loading…
Reference in a new issue