diff --git a/src/gl-setup b/src/gl-setup index 4f9ccd1..0dd8c84 100755 --- a/src/gl-setup +++ b/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 # 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 admin_name= -if [[ -n $pubkey_file ]] +if [ -n "$pubkey_file" ] then - [[ $pubkey_file =~ .pub$ ]] || die "$pubkey_file must end in .pub" - [[ -f $pubkey_file ]] || die "cant find $pubkey_file" + echo $pubkey_file | grep '.pub$' >/dev/null || die "$pubkey_file must end in .pub" + [ -f $pubkey_file ] || die "cant find $pubkey_file" admin_name=$(basename $pubkey_file .pub) fi -if [[ -f ~/.gitolite.rc ]] +if [ -f ~/.gitolite.rc ] 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 /^\$/;' < ~/.gitolite.rc | sort > .oldvars comm -23 .newvars .oldvars > .diffvars - if [[ -s .diffvars ]] + if [ -s .diffvars ] then cp $GL_PACKAGE_CONF/example.gitolite.rc ~/.gitolite.rc.new echo new version of the rc file saved in ~/.gitolite.rc.new @@ -48,7 +48,7 @@ then fi rm -f .newvars .oldvars .diffvars 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 fi @@ -66,7 +66,7 @@ gl-install -q GL_ADMINDIR=$(cd;perl -e 'do ".gitolite.rc"; print $GL_ADMINDIR') REPO_BASE=$( cd;perl -e 'do ".gitolite.rc"; print $REPO_BASE' ) -[[ -f $GL_ADMINDIR/conf/gitolite.conf ]] || { +[ -f $GL_ADMINDIR/conf/gitolite.conf ] || { cat < $GL_ADMINDIR/conf/gitolite.conf repo gitolite-admin RW+ = $admin_name @@ -75,7 +75,7 @@ REPO_BASE=$( cd;perl -e 'do ".gitolite.rc"; print $REPO_BASE' ) RW+ = @all EOF } -[[ -n $pubkey_file ]] && cp $pubkey_file $GL_ADMINDIR/keydir +[ -n "$pubkey_file" ] && cp $pubkey_file $GL_ADMINDIR/keydir touch $HOME/.ssh/authorized_keys gl-compile-conf -q