easy install (+doc): make it run from msys. Here's how:

- all $HOME/blah becomes "$HOME/blah" (bl**dy "Documents and Settings" crap)
  - replace bash regex with perl, and in one case replace the check with
    something else
  - rsync changed to appropriate scp
  - since we no longer insist on running from a specific directory, create
    tmpgli dir *after* you cd to the right place
This commit is contained in:
Sitaram Chamarty 2009-11-18 14:37:04 +05:30
parent 0bdf1f360f
commit 23be2b6240
2 changed files with 35 additions and 40 deletions

View file

@ -1,5 +1,7 @@
# installing gitolite # installing gitolite
[Update 2009-11-18: easy install now works from msysgit also!]
This document tells you how to install gitolite. After the install is done, This document tells you how to install gitolite. After the install is done,
you may want to see the [admin document][admin] for adding users, repos, etc. you may want to see the [admin document][admin] for adding users, repos, etc.
@ -141,22 +143,18 @@ You need the following software on it:
#### install workstation #### install workstation
Installing or upgrading the gitolite software itself is best done by running Installing or upgrading the gitolite software itself is best done by running
the easy-install program from a clone, usually on a different machine. the easy-install program from a gitolite clone.
This script is heavily dependent on bash, so you need a unix machine that has This script is heavily dependent on bash, so you need a machine with a bash
a bash shell available. Unlike the server side dependency mentioned above, shell. Even the bash that comes with msysgit is fine, if you don't have a
this bash dependency is probably permament. Linux box handy.
*However*, you do not need to use this machine every day. Day to day If you have neither Linux nor Windows+msysgit, you still have a few
administration of gitolite (adding users, repos, etc) can be done from alternatives:
anywhere; see next section.
If you do not have such a machine, you have the following alternatives: * use a different userid on the same server (assuming it has bash)
* use the same userid on the same server (same assumption)
* use a different userid on the same server * manually simulate the script directly on the server (doable, but tedious)
* use the same userid on the same server!
* (either of the above cases makes bash mandatory on the server, by the way)
* manually simulate the script directly on the server; doable, but tedious
#### admin workstation(s) #### admin workstation(s)
@ -168,10 +166,7 @@ done by cloning this repo, making changes to a file called
`conf/gitolite.conf`, adding users' pubkeys to `keydir/`, and pushing the `conf/gitolite.conf`, adding users' pubkeys to `keydir/`, and pushing the
changes back to the server. changes back to the server.
Which means all this can be done from *any* machine, even Windows. [Just make Which means all this can be done from *any* machine. You'll normally do it
sure your pubkey (from the Windows machine) has been added and permissions from the same machine you used to install gitolite, but it doesn't have to be
given to allow you to push to the gitolite-admin repo. This is also how other the same one, as long as your pubkey has been added and permissions given to
people can be added as "admins": add their pubkey to as allow you to push to the gitolite-admin repo.
`keydir/<username>.pub`, and give `<username>` at least `RW` permissions on
the `gitolite-admin` repo in the `conf/gitolite.conf` file.]

View file

@ -33,10 +33,10 @@ fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
main() { main() {
setup_tempdir
basic_sanity "$@" basic_sanity "$@"
setup_tempdir
version_info "$@" version_info "$@"
[[ -n $admin_name ]] && setup_local_ssh [[ -n $admin_name ]] && setup_local_ssh
@ -140,11 +140,9 @@ basic_sanity() {
# MANUAL: this *must* be run as "src/gl-easy-install", not by cd-ing to # MANUAL: this *must* be run as "src/gl-easy-install", not by cd-ing to
# src and then running "./gl-easy-install" # src and then running "./gl-easy-install"
[[ $0 =~ ^src/gl-easy-install$ ]] || bindir=${0%/*}
{ # switch to parent of bindir; we assume the conf files are all there
die "please cd to the gitolite repo top level directory and run this as cd $bindir; cd ..
'src/gl-easy-install'"
}
# are we in quiet mode? # are we in quiet mode?
quiet= quiet=
@ -163,14 +161,16 @@ basic_sanity() {
admin_name=$3 admin_name=$3
# but if the 3rd arg is a number, that's a port number, and the 4th arg is # but if the 3rd arg is a number, that's a port number, and the 4th arg is
# the admin_name # the admin_name
if [[ $3 =~ ^[0-9]+$ ]] if echo $3 | perl -lne 'exit 1 unless /^[0-9]+$/'
then then
port=$3 port=$3
admin_name=$4 admin_name=$4
fi fi
[[ "$user" =~ [^a-zA-Z0-9._-] ]] && die "user '$user' invalid" echo $user | perl -lne 'exit 1 if /[^a-zA-Z0-9._-]/' ||
[[ -n $admin_name ]] && [[ "$admin_name" =~ [^a-zA-Z0-9._-] ]] && die "admin_name '$admin_name' invalid" die "user '$user' invalid"
echo $admin_name | perl -lne 'exit 1 if /[^a-zA-Z0-9._-]/' ||
die "admin_name '$admin_name' invalid"
# MANUAL: make sure you're in the gitolite directory, at the top level. # MANUAL: make sure you're in the gitolite directory, at the top level.
# The following files should all be visible: # The following files should all be visible:
@ -225,11 +225,11 @@ setup_local_ssh() {
prompt "setting up keypair..." "$v_setting_up_keypair" prompt "setting up keypair..." "$v_setting_up_keypair"
if [[ -f $HOME/.ssh/$admin_name.pub ]] if [[ -f "$HOME/.ssh/$admin_name.pub" ]]
then then
prompt " ...reusing $HOME/.ssh/$admin_name.pub..." "$v_reuse_pubkey" prompt " ...reusing $HOME/.ssh/$admin_name.pub..." "$v_reuse_pubkey"
else else
ssh-keygen -t rsa -f $HOME/.ssh/$admin_name || die "ssh-keygen failed for some reason..." ssh-keygen -t rsa -f "$HOME/.ssh/$admin_name" || die "ssh-keygen failed for some reason..."
fi fi
# MANUAL: copy the pubkey created to the server, say to /tmp. This would # MANUAL: copy the pubkey created to the server, say to /tmp. This would
@ -245,7 +245,7 @@ setup_local_ssh() {
if ssh-add -l &>/dev/null if ssh-add -l &>/dev/null
then then
prompt " ...adding key to agent..." "$v_ssh_add" prompt " ...adding key to agent..." "$v_ssh_add"
ssh-add $HOME/.ssh/$admin_name ssh-add "$HOME/.ssh/$admin_name"
fi fi
# MANUAL: you now need to add some lines to the end of your ~/.ssh/config # MANUAL: you now need to add some lines to the end of your ~/.ssh/config
@ -266,14 +266,14 @@ setup_local_ssh() {
port $port port $port
identityfile ~/.ssh/$admin_name" > $tmpgli/.gl-stanza identityfile ~/.ssh/$admin_name" > $tmpgli/.gl-stanza
if grep 'host *gitolite' $HOME/.ssh/config &>/dev/null if grep 'host *gitolite' "$HOME/.ssh/config" &>/dev/null
then then
prompt "found gitolite para in ~/.ssh/config; assuming it is correct..." "$v_found_para" prompt "found gitolite para in ~/.ssh/config; assuming it is correct..." "$v_found_para"
else else
prompt "creating gitolite para in ~/.ssh/config..." "$v_creating_para" prompt "creating gitolite para in ~/.ssh/config..." "$v_creating_para"
cat $tmpgli/.gl-stanza >> $HOME/.ssh/config cat $tmpgli/.gl-stanza >> "$HOME/.ssh/config"
# if the file didn't exist at all, it might have the wrong permissions # if the file didn't exist at all, it might have the wrong permissions
chmod 644 $HOME/.ssh/config chmod 644 "$HOME/.ssh/config"
fi fi
} }
@ -288,7 +288,7 @@ copy_gl() {
# have to create the directory first. # have to create the directory first.
ssh -p $port $user@$host mkdir -p gitolite-install ssh -p $port $user@$host mkdir -p gitolite-install
rsync $quiet -e "ssh -p $port" -a src conf doc $user@$host:gitolite-install/ scp $quiet -P $port -r src conf doc $user@$host:gitolite-install/
rm -f src/VERSION rm -f src/VERSION
# MANUAL: now log on to the server (ssh git@server) and get a command # MANUAL: now log on to the server (ssh git@server) and get a command
@ -384,7 +384,7 @@ repo testing
# send the config and the key to the remote # send the config and the key to the remote
scp $quiet -P $port $tmpgli/gitolite.conf $user@$host:$GL_ADMINDIR/conf/ scp $quiet -P $port $tmpgli/gitolite.conf $user@$host:$GL_ADMINDIR/conf/
scp $quiet -P $port $HOME/.ssh/$admin_name.pub $user@$host:$GL_ADMINDIR/keydir scp $quiet -P $port "$HOME/.ssh/$admin_name.pub" $user@$host:$GL_ADMINDIR/keydir
# MANUAL: cd to $GL_ADMINDIR and run "src/gl-compile-conf" # MANUAL: cd to $GL_ADMINDIR and run "src/gl-compile-conf"
ssh -p $port $user@$host "cd $GL_ADMINDIR; src/gl-compile-conf $quiet" ssh -p $port $user@$host "cd $GL_ADMINDIR; src/gl-compile-conf $quiet"
@ -426,7 +426,7 @@ GIT_WORK_TREE=$GL_ADMINDIR git commit -am start --allow-empty
prompt "cloning gitolite-admin repo..." "$v_cloning" prompt "cloning gitolite-admin repo..." "$v_cloning"
cleanup cleanup
cd $HOME cd "$HOME"
git clone gitolite:gitolite-admin.git git clone gitolite:gitolite-admin.git
# MANUAL: be sure to read the message below; this applies to you too... # MANUAL: be sure to read the message below; this applies to you too...
@ -464,7 +464,7 @@ successfully cloned and pushed the gitolite-admin repo. After that, install
'keychain' or something similar, and add the following command to your bashrc 'keychain' or something similar, and add the following command to your bashrc
(since this is a non-default key) (since this is a non-default key)
ssh-add \\\$HOME/.ssh/\$admin_name ssh-add "\\\$HOME/.ssh/\$admin_name"
This makes using passphrases very convenient. This makes using passphrases very convenient.
" "