Skip to content

Commit

Permalink
make gl-system-install easier to run
Browse files Browse the repository at this point in the history
make the arguments optional (with documented defaults) plus they need
not exist a priori, reducing one command (the silly mkdir!) that the
user has to run.

All this is preparatory to deprecating the from-client method.  We've
even switched the test suite to 'non-root' method now
  • Loading branch information
sitaramc committed May 28, 2011
1 parent 31cd56b commit 660fad9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
33 changes: 28 additions & 5 deletions src/gl-system-install
Expand Up @@ -5,25 +5,32 @@

usage() { echo "
Usage:
$0 shared-bin-dir shared-conf-dir shared-hooks-dir
$0 [shared-bin-dir shared-conf-dir shared-hooks-dir]
Example:
Examples:
# as root
$0
# this defaults to:
$0 /usr/local/bin /var/gitolite/conf /var/gitolite/hooks
# as a normal user
$0
# this defaults to:
$0 $HOME/bin $HOME/share/gitolite/conf $HOME/share/gitolite/hooks
In this example, all the binaries go to /usr/local/bin, and the shared
conf and hooks files/directories go to the other 2 directories given. All
the 3 paths supplied MUST be absolute.
[RPM packagers: you can supply a 4th argument to specify a 'buildroot'
directory. DEB folks would call this a 'DESTDIR', I believe.]
directory. DEB folks would call this a 'DESTDIR', I believe. In this
usage the first 3 arguments are NOT optional]
"
exit 1;
}

die() { echo "$@"; echo; usage; exit 1; } >&2

[ -z "$3" ] && usage

validate_dir() {
echo $1 | grep ^/ >/dev/null || die "$1 should be an absolute path"
[ -d $1 ] || mkdir -p $1 || die "$1 does not exist and could not be created"
Expand All @@ -33,6 +40,22 @@ validate_dir() {
buildroot=$4;
[ -n "$buildroot" ] && validate_dir $buildroot
[ -n "$buildroot" ] && buildroot=$buildroot/

# either all 3 args must be supplied or none at all
[ -n "$1" ] && [ -z "$3" ] && die "I need all 3 directories or none at all"
# supply default values to args 1, 2, and 3 if not provided
[ -z "$1" ] && {
euid=$(perl -e 'print $>')
if [ "$euid" = "0" ]
then
set /usr/local/bin /var/gitolite/conf /var/gitolite/hooks
else
set $HOME/bin $HOME/share/gitolite/conf $HOME/share/gitolite/hooks
fi
echo "using default value for EUID=$euid:" >&2
echo "$@" >&2
}

gl_bin_dir=$1; validate_dir $buildroot$gl_bin_dir
gl_conf_dir=$2; validate_dir $buildroot$gl_conf_dir
gl_hooks_dir=$3; validate_dir $buildroot$gl_hooks_dir
Expand Down
23 changes: 20 additions & 3 deletions t/install-gitolite
@@ -1,5 +1,6 @@
#!/bin/bash


export TESTDIR=$PWD

# prepare local ssh
Expand All @@ -16,15 +17,31 @@ chmod 600 ~/.ssh/u?

# blank out the server side
echo the next command MAY ask for a password
ssh gitolite-test@localhost rm -rf .ssh .gitolite .gitolite.rc repositories gitolite-install /tmp/glrb
ssh gitolite-test@localhost rm -rf .ssh .gitolite .gitolite.rc repositories /tmp/glrb bin share
echo the next command SHOULD ask for a password
ssh-copy-id -i ~/.ssh/id_rsa gitolite-test@localhost
echo the next command should NOT ask for a password
scp ~/.ssh/tester.pub gitolite-test@localhost:

# install it
../src/gl-easy-install -q gitolite-test localhost tester
echo installing whatever is here now...
# ../src/gl-easy-install -q gitolite-test localhost tester
cat <<EOF | ssh gitolite-test@localhost
cd gitolite
git describe --tags --long HEAD > conf/VERSION
src/gl-system-install
cd
gl-setup -q tester.pub
EOF
echo =============================
echo
echo
echo

# add 6 keys
rm -rf ~/gitolite-admin
cd
git clone gitolite:gitolite-admin
cd ~/gitolite-admin
cp $TESTDIR/keys/u*pub keydir
git add keydir; git commit -m 'added 6 keys'
Expand All @@ -34,5 +51,5 @@ git push
cd
tar cf rollback.tar gitolite-admin
ssh gitolite-test@localhost mkdir -p repositories /tmp/glrb
ssh gitolite-test@localhost tar cf rollback.tar .ssh .gitolite .gitolite.rc repositories gitolite-install
ssh gitolite-test@localhost tar cf rollback.tar .ssh .gitolite .gitolite.rc repositories bin share
ssh gitolite-test@localhost tar -C /tmp -cf \$HOME/rollback2.tar glrb
5 changes: 4 additions & 1 deletion t/keys/config
@@ -1,4 +1,7 @@
host u?
host gitolite
identityfile ~/.ssh/tester

host u? gitolite
user gitolite-test
hostname localhost
host u1
Expand Down
2 changes: 1 addition & 1 deletion t/rollback.server
@@ -1,7 +1,7 @@
#!/bin/bash

cd
rm -rf .ssh .gitolite .gitolite.rc repositories gitolite-install /tmp/glrb
rm -rf .ssh .gitolite .gitolite.rc repositories gitolite-install /tmp/glrb bin share
tar xf rollback.tar
( cd /tmp; tar xf ~/rollback2.tar )

Expand Down

0 comments on commit 660fad9

Please sign in to comment.