easy install: add "-q" option for experts; see usage message
This commit is contained in:
parent
2f6ed42fcd
commit
aef540c659
|
@ -17,6 +17,14 @@ set -e
|
||||||
|
|
||||||
die() { echo "$@"; echo; echo "run $0 again without any arguments for help and tips"; exit 1; }
|
die() { echo "$@"; echo; echo "run $0 again without any arguments for help and tips"; exit 1; }
|
||||||
prompt() {
|
prompt() {
|
||||||
|
# receives two arguments. A short piece of text to be displayed, without
|
||||||
|
# pausing, in "quiet" mode, and a much longer one to be displayed, *with*
|
||||||
|
# a pause, in normal (verbose) mode
|
||||||
|
[[ $quiet == -q ]] && [[ -n $1 ]] && {
|
||||||
|
echo "$1"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
shift
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo ------------------------------------------------------------------------
|
echo ------------------------------------------------------------------------
|
||||||
|
@ -26,7 +34,10 @@ prompt() {
|
||||||
}
|
}
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOFU
|
cat <<EOFU
|
||||||
Usage: $0 user host port admin_name
|
Usage: $0 [-q] user host port admin_name
|
||||||
|
|
||||||
|
- (optional) "-q" as first arg sets "quiet" mode: no verbose descriptions of
|
||||||
|
what is going on, no pauses unless absolutely necessary
|
||||||
- "user" is the username on the server where you will be installing gitolite
|
- "user" is the username on the server where you will be installing gitolite
|
||||||
- "host" is that server's hostname (or IP address is also fine)
|
- "host" is that server's hostname (or IP address is also fine)
|
||||||
- "port" is optional
|
- "port" is optional
|
||||||
|
@ -35,9 +46,6 @@ Usage: $0 user host port admin_name
|
||||||
|
|
||||||
Example usage: $0 git my.git.server sitaram
|
Example usage: $0 git my.git.server sitaram
|
||||||
|
|
||||||
Output:
|
|
||||||
- a proper gitolite admin repo in $HOME/gitolite-admin
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- "user" and "admin_name" must be simple names -- no special characters etc
|
- "user" and "admin_name" must be simple names -- no special characters etc
|
||||||
please (only alphanumerics, dot, hyphen, underscore)
|
please (only alphanumerics, dot, hyphen, underscore)
|
||||||
|
@ -55,11 +63,6 @@ Pre-requisites:
|
||||||
|
|
||||||
**DO NOT RUN THIS PROGRAM UNTIL THAT WORKS**
|
**DO NOT RUN THIS PROGRAM UNTIL THAT WORKS**
|
||||||
|
|
||||||
Errors:
|
|
||||||
- if you get a "pubkey [...filename...] exists" error, it is either leftover
|
|
||||||
from a previous, failed, run, or a genuine file you need. Decide which it
|
|
||||||
is, and remove it and retry, or use a different "admin_name", respectively.
|
|
||||||
|
|
||||||
EOFU
|
EOFU
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +81,13 @@ EOFU
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# are we in quiet mode?
|
||||||
|
quiet=
|
||||||
|
[[ "$1" == "-q" ]] && {
|
||||||
|
quiet=-q
|
||||||
|
shift
|
||||||
|
}
|
||||||
|
|
||||||
# MANUAL: (info) we'll use "git" as the user, "server" as the host, and
|
# MANUAL: (info) we'll use "git" as the user, "server" as the host, and
|
||||||
# "sitaram" as the admin_name in example commands shown below, if any
|
# "sitaram" as the admin_name in example commands shown below, if any
|
||||||
|
|
||||||
|
@ -120,7 +130,8 @@ ssh -p $port -o PasswordAuthentication=no $user@$host true ||
|
||||||
# line). For example, "ssh-keygen -t rsa ~/.ssh/sitaram"; this would create
|
# line). For example, "ssh-keygen -t rsa ~/.ssh/sitaram"; this would create
|
||||||
# two files in ~/.ssh (sitaram and sitaram.pub)
|
# two files in ~/.ssh (sitaram and sitaram.pub)
|
||||||
|
|
||||||
prompt "the next command will create a new keypair for your gitolite access
|
prompt "setting up keypair..." \
|
||||||
|
"the next command will create a new keypair for your gitolite access
|
||||||
|
|
||||||
The pubkey will be $HOME/.ssh/$admin_name.pub. You will have to choose a
|
The pubkey will be $HOME/.ssh/$admin_name.pub. You will have to choose a
|
||||||
passphrase or hit enter for none. I recommend not having a passphrase for
|
passphrase or hit enter for none. I recommend not having a passphrase for
|
||||||
|
@ -138,7 +149,8 @@ prompt "the next command will create a new keypair for your gitolite access
|
||||||
|
|
||||||
if [[ -f $HOME/.ssh/$admin_name.pub ]]
|
if [[ -f $HOME/.ssh/$admin_name.pub ]]
|
||||||
then
|
then
|
||||||
prompt "Hmmm... pubkey $HOME/.ssh/$admin_name.pub exists; should I just re-use it?
|
prompt " ...reusing $HOME/.ssh/$admin_name.pub..." \
|
||||||
|
"Hmmm... pubkey $HOME/.ssh/$admin_name.pub exists; should I just re-use it?
|
||||||
Be sure you remember the passphrase, if you gave one when you created it!"
|
Be sure you remember the passphrase, if you gave one when you created it!"
|
||||||
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..."
|
||||||
|
@ -155,7 +167,8 @@ fi
|
||||||
|
|
||||||
if ssh-add -l &>/dev/null
|
if ssh-add -l &>/dev/null
|
||||||
then
|
then
|
||||||
prompt "you're running ssh-agent. We'll try and do an ssh-add of the
|
prompt " ...adding key to agent..." \
|
||||||
|
"you're running ssh-agent. We'll try and do an ssh-add of the
|
||||||
private key we just created, otherwise this key won't get picked up. If
|
private key we just created, otherwise this key won't get picked up. If
|
||||||
you specified a passphrase in the previous step, you'll get asked for one
|
you specified a passphrase in the previous step, you'll get asked for one
|
||||||
now -- type in the same one."
|
now -- type in the same one."
|
||||||
|
@ -184,7 +197,8 @@ host gitolite
|
||||||
|
|
||||||
if grep 'host *gitolite' $HOME/.ssh/config &>/dev/null
|
if grep 'host *gitolite' $HOME/.ssh/config &>/dev/null
|
||||||
then
|
then
|
||||||
prompt "your \$HOME/.ssh/config already has settings for gitolite. I will
|
prompt "found gitolite para in ~/.ssh/config; assuming it is correct..." \
|
||||||
|
"your \$HOME/.ssh/config already has settings for gitolite. I will
|
||||||
assume they're correct, but if they're not, please edit that file, delete
|
assume they're correct, but if they're not, please edit that file, delete
|
||||||
that paragraph (that line and the following few lines), Ctrl-C, and rerun.
|
that paragraph (that line and the following few lines), Ctrl-C, and rerun.
|
||||||
|
|
||||||
|
@ -193,7 +207,8 @@ then
|
||||||
$(cat ~/.ssh/.gl-stanza)"
|
$(cat ~/.ssh/.gl-stanza)"
|
||||||
|
|
||||||
else
|
else
|
||||||
prompt "creating settings for your gitolite access in $HOME/.ssh/config;
|
prompt "creating gitolite para in ~/.ssh/config..." \
|
||||||
|
"creating settings for your gitolite access in $HOME/.ssh/config;
|
||||||
these are the lines that will be appended to your ~/.ssh/config:
|
these are the lines that will be appended to your ~/.ssh/config:
|
||||||
$(cat ~/.ssh/.gl-stanza)"
|
$(cat ~/.ssh/.gl-stanza)"
|
||||||
|
|
||||||
|
@ -212,7 +227,7 @@ rm $HOME/.ssh/.gl-stanza
|
||||||
# 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 -e "ssh -p $port" -a src conf doc $user@$host:gitolite-install/
|
rsync $quiet -e "ssh -p $port" -a src conf doc $user@$host:gitolite-install/
|
||||||
|
|
||||||
# MANUAL: now log on to the server (ssh git@server) and get a command line.
|
# MANUAL: now log on to the server (ssh git@server) and get a command line.
|
||||||
# This step is for your convenience; the script does it all from the client
|
# This step is for your convenience; the script does it all from the client
|
||||||
|
@ -223,7 +238,8 @@ rsync -e "ssh -p $port" -a src conf doc $user@$host:gitolite-install/
|
||||||
# change any paths. Make a note of the GL_ADMINDIR and REPO_BASE paths; you
|
# change any paths. Make a note of the GL_ADMINDIR and REPO_BASE paths; you
|
||||||
# will need them later
|
# will need them later
|
||||||
|
|
||||||
prompt "the gitolite rc file needs to be edited by hand. The defaults
|
prompt "finding/creating gitolite rc..." \
|
||||||
|
"the gitolite rc file needs to be edited by hand. The defaults
|
||||||
are sensible, so if you wish, you can just exit the editor.
|
are sensible, so if you wish, you can just exit the editor.
|
||||||
|
|
||||||
Otherwise, make any changes you wish and save it. Read the comments to
|
Otherwise, make any changes you wish and save it. Read the comments to
|
||||||
|
@ -233,19 +249,20 @@ prompt "the gitolite rc file needs to be edited by hand. The defaults
|
||||||
all the paths etc. represent paths on the server!"
|
all the paths etc. represent paths on the server!"
|
||||||
|
|
||||||
# lets try and get the file from there first
|
# lets try and get the file from there first
|
||||||
if scp -P $port $user@$host:.gitolite.rc .
|
if scp -P $port $user@$host:.gitolite.rc . &>/dev/null
|
||||||
then
|
then
|
||||||
prompt "Oh hey... you already had a '.gitolite.rc' file on the server.
|
prompt " ...trying to reuse existing rc" \
|
||||||
|
"Oh hey... you already had a '.gitolite.rc' file on the server.
|
||||||
Let's see if we can use that instead of the default one..."
|
Let's see if we can use that instead of the default one..."
|
||||||
sort < .gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > glrc.old
|
sort < .gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > glrc.old
|
||||||
sort < conf/example.gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > glrc.new
|
sort < conf/example.gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > glrc.new
|
||||||
if diff -u glrc.old glrc.new
|
if diff -u glrc.old glrc.new
|
||||||
then
|
then
|
||||||
${VISUAL:-${EDITOR:-vi}} .gitolite.rc
|
[[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} .gitolite.rc
|
||||||
else
|
else
|
||||||
prompt " looks like you're upgrading, and there are some new rc
|
prompt "" \
|
||||||
variables that this version is expecting that your old rc file doesn't
|
" looks like you're upgrading, and there are some new rc variables
|
||||||
have.
|
that this version is expecting that your old rc file doesn't have.
|
||||||
|
|
||||||
I'm going to run your editor with two filenames. The first is the
|
I'm going to run your editor with two filenames. The first is the
|
||||||
example file from this gitolite version. It will have a block (code
|
example file from this gitolite version. It will have a block (code
|
||||||
|
@ -264,13 +281,14 @@ then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cp conf/example.gitolite.rc .gitolite.rc
|
cp conf/example.gitolite.rc .gitolite.rc
|
||||||
${VISUAL:-${EDITOR:-vi}} .gitolite.rc
|
[[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} .gitolite.rc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy the rc across
|
# copy the rc across
|
||||||
scp -P $port .gitolite.rc $user@$host:
|
scp $quiet -P $port .gitolite.rc $user@$host:
|
||||||
|
|
||||||
prompt "ignore any 'please edit this file' or 'run this command' type
|
prompt "installing/upgrading..." \
|
||||||
|
"ignore any 'please edit this file' or 'run this command' type
|
||||||
lines in the next set of command outputs coming up. They're only relevant
|
lines in the next set of command outputs coming up. They're only relevant
|
||||||
for a manual install, not this one..."
|
for a manual install, not this one..."
|
||||||
|
|
||||||
|
@ -281,7 +299,7 @@ REPO_BASE=$( ssh -p $port $user@$host "perl -e 'do \".gitolite.rc\"; print \$RE
|
||||||
# MANUAL: still in the "gitolite-install" directory? Good. Run
|
# MANUAL: still in the "gitolite-install" directory? Good. Run
|
||||||
# "src/install.pl"
|
# "src/install.pl"
|
||||||
|
|
||||||
ssh -p $port $user@$host "cd gitolite-install; src/install.pl"
|
ssh -p $port $user@$host "cd gitolite-install; src/install.pl $quiet"
|
||||||
|
|
||||||
# MANUAL: if you're upgrading, just go to your clone of the admin repo, make a
|
# MANUAL: if you're upgrading, just go to your clone of the admin repo, make a
|
||||||
# dummy change, and push. (This assumes that you didn't change the
|
# dummy change, and push. (This assumes that you didn't change the
|
||||||
|
@ -294,7 +312,8 @@ ssh -p $port $user@$host "cd gitolite-install; src/install.pl"
|
||||||
upgrade=0
|
upgrade=0
|
||||||
if ssh -p $port $user@$host cat $GL_ADMINDIR/keydir/$admin_name.pub &> /dev/null
|
if ssh -p $port $user@$host cat $GL_ADMINDIR/keydir/$admin_name.pub &> /dev/null
|
||||||
then
|
then
|
||||||
prompt "this looks like an upgrade, based on the fact that a file called
|
prompt "upgrade done!" \
|
||||||
|
"this looks like an upgrade, based on the fact that a file called
|
||||||
$admin_name.pub already exists in $GL_ADMINDIR/keydir on the server.
|
$admin_name.pub already exists in $GL_ADMINDIR/keydir on the server.
|
||||||
|
|
||||||
Please go to your clone of the admin repo, make a dummy change (like maybe
|
Please go to your clone of the admin repo, make a dummy change (like maybe
|
||||||
|
@ -326,11 +345,11 @@ repo testing
|
||||||
" > gitolite.conf
|
" > gitolite.conf
|
||||||
|
|
||||||
# send the config and the key to the remote
|
# send the config and the key to the remote
|
||||||
scp -P $port gitolite.conf $user@$host:$GL_ADMINDIR/conf/
|
scp $quiet -P $port gitolite.conf $user@$host:$GL_ADMINDIR/conf/
|
||||||
scp -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"
|
ssh -p $port $user@$host "cd $GL_ADMINDIR; src/gl-compile-conf $quiet"
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# hey lets go the whole hog on this; setup push-to-admin!
|
# hey lets go the whole hog on this; setup push-to-admin!
|
||||||
|
@ -356,13 +375,14 @@ GIT_WORK_TREE=$GL_ADMINDIR git commit -am start --allow-empty
|
||||||
# properly. The install program does this. So cd back to the
|
# properly. The install program does this. So cd back to the
|
||||||
# "gitolite-install" directory and run "src/install.pl"
|
# "gitolite-install" directory and run "src/install.pl"
|
||||||
|
|
||||||
ssh -p $port $user@$host "cd gitolite-install; src/install.pl"
|
ssh -p $port $user@$host "cd gitolite-install; src/install.pl $quiet"
|
||||||
|
|
||||||
# MANUAL: you're done! Log out of the server, come back to your workstation,
|
# MANUAL: you're done! Log out of the server, come back to your workstation,
|
||||||
# and clone the admin repo using "git clone gitolite:gitolite-admin.git", or
|
# and clone the admin repo using "git clone gitolite:gitolite-admin.git", or
|
||||||
# pull once again if you already have a clone
|
# pull once again if you already have a clone
|
||||||
|
|
||||||
prompt "now we will clone the gitolite-admin repo to your workstation
|
prompt "cloning gitolite-admin repo..." \
|
||||||
|
"now we will clone the gitolite-admin repo to your workstation
|
||||||
and see if it all hangs together. We'll do this in your \$HOME for now,
|
and see if it all hangs together. We'll do this in your \$HOME for now,
|
||||||
and you can move it elsewhere later if you wish to."
|
and you can move it elsewhere later if you wish to."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue