2009-10-10 09:08:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# easy install for gitolite
|
|
|
|
|
2009-10-11 05:01:59 +02:00
|
|
|
# you run this on the client side, and it takes care of all the server side
|
2009-10-11 02:21:19 +02:00
|
|
|
# work. You don't have to do anything on the server side directly
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-10-11 05:01:59 +02:00
|
|
|
# to do a manual install (since I have tested this only on Linux), open this
|
|
|
|
# script in a nice, syntax coloring, text editor and follow the instructions
|
|
|
|
# prefixed by the word "MANUAL" in the comments below :-)
|
|
|
|
|
2009-10-10 09:08:22 +02:00
|
|
|
# run without any arguments for "usage" info
|
|
|
|
|
|
|
|
# important setting: bail on any errors (else we have to check every single
|
|
|
|
# command!)
|
|
|
|
set -e
|
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
2009-11-06 04:29:32 +01:00
|
|
|
# bootstrap and main
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
2009-11-06 04:29:32 +01:00
|
|
|
if [[ $1 != boot/strap ]]
|
|
|
|
then
|
|
|
|
# did someone tell you you can't call functions before they're defined in
|
|
|
|
# bash? Don't believe everything you hear ;-)
|
|
|
|
. $0 boot/strap
|
|
|
|
main "$@"
|
|
|
|
cleanup
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# no direct executable statements after this; only functions
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
main() {
|
|
|
|
basic_sanity "$@"
|
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
setup_tempdir
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
version_info "$@"
|
|
|
|
|
|
|
|
[[ -n $admin_name ]] && setup_local_ssh
|
|
|
|
|
|
|
|
copy_gl # src, conf, etc
|
|
|
|
|
|
|
|
run_install
|
|
|
|
|
2009-11-22 06:12:32 +01:00
|
|
|
[[ $upgrade == 0 ]] && initial_conf_key
|
2009-11-05 17:46:18 +01:00
|
|
|
|
2009-11-22 06:12:32 +01:00
|
|
|
# MANUAL: cd to $GL_ADMINDIR and run "src/gl-compile-conf"
|
2010-04-16 09:19:07 +02:00
|
|
|
ssh $p_port $user@$host "cd $GL_ADMINDIR; \$PWD/src/gl-compile-conf $quiet"
|
2009-11-06 04:29:32 +01:00
|
|
|
|
|
|
|
setup_pta
|
2009-11-22 06:12:32 +01:00
|
|
|
|
|
|
|
clone_it
|
2009-11-06 04:29:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# setup temp files
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
setup_tempdir() {
|
|
|
|
export tmpgli=tmp-gl-install
|
|
|
|
trap cleanup 0
|
|
|
|
mkdir -p $tmpgli
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
rm -rf $tmpgli
|
|
|
|
}
|
2009-10-30 13:13:26 +01:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# service functions
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
die() { echo "$@"; echo; echo "run $0 without any arguments for help and tips"; cleanup; exit 1; }
|
2009-10-10 09:08:22 +02:00
|
|
|
prompt() {
|
2009-10-25 09:32:04 +01:00
|
|
|
# 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 ]] && {
|
2009-11-06 04:29:32 +01:00
|
|
|
eval "echo \"$1\""
|
2009-10-25 09:32:04 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
shift
|
2009-10-10 09:08:22 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo ------------------------------------------------------------------------
|
2009-11-06 04:29:32 +01:00
|
|
|
eval "echo \"$1\""
|
2009-10-10 09:08:22 +02:00
|
|
|
echo
|
|
|
|
read -p '...press enter to continue or Ctrl-C to bail out'
|
|
|
|
}
|
|
|
|
usage() {
|
|
|
|
cat <<EOFU
|
2009-11-05 17:46:18 +01:00
|
|
|
Usage: $0 [-q] user host [port] admin_name # install
|
|
|
|
$0 [-q] user host [port] # upgrade
|
2009-10-25 09:32:04 +01:00
|
|
|
|
|
|
|
- (optional) "-q" as first arg sets "quiet" mode: no verbose descriptions of
|
|
|
|
what is going on, no pauses unless absolutely necessary
|
2009-10-10 09:08:22 +02:00
|
|
|
- "user" is the username on the server where you will be installing gitolite
|
2009-11-05 17:46:18 +01:00
|
|
|
- "host" is that server's hostname (or IP address)
|
|
|
|
- "port" is the ssh server port on "host"; optional, defaults to 22
|
|
|
|
- "admin_name" is *your* name as it should appear in the eventual gitolite
|
2009-11-06 04:29:32 +01:00
|
|
|
config file. For upgrades (ie., gitolite is already installed on the
|
|
|
|
server), this argument is not needed, and will be *ignored* if provided.
|
2009-10-10 09:08:22 +02:00
|
|
|
|
|
|
|
Example usage: $0 git my.git.server sitaram
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
- "user" and "admin_name" must be simple names -- no special characters etc
|
|
|
|
please (only alphanumerics, dot, hyphen, underscore)
|
|
|
|
- traditionally, the "user" is "git", but it can be anything you want
|
|
|
|
- "admin_name" should be your name, for clarity, or whoever will be the
|
|
|
|
gitolite admin
|
|
|
|
|
|
|
|
Pre-requisites:
|
|
|
|
- you must already have pubkey based access to user@host. If you currently
|
2009-10-21 15:49:00 +02:00
|
|
|
only have password access, use "ssh-copy-id" or something equivalent (or
|
|
|
|
copy the key manually). Somehow (doesn't matter how), get to the point
|
|
|
|
where you can type "ssh user@host" and get a command line.
|
|
|
|
|
|
|
|
**DO NOT RUN THIS PROGRAM UNTIL THAT WORKS**
|
2009-10-10 09:08:22 +02:00
|
|
|
|
|
|
|
EOFU
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2009-10-12 06:23:30 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# basic sanity / argument checks
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
basic_sanity() {
|
2009-11-13 00:33:09 +01:00
|
|
|
# MANUAL: this *must* be run as "src/gl-easy-install", not by cd-ing to
|
|
|
|
# src and then running "./gl-easy-install"
|
2009-10-12 06:23:30 +02:00
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
bindir=${0%/*}
|
|
|
|
# switch to parent of bindir; we assume the conf files are all there
|
2009-11-22 06:12:32 +01:00
|
|
|
cd "$bindir"; cd ..
|
2009-10-12 06:23:30 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# are we in quiet mode?
|
|
|
|
quiet=
|
|
|
|
[[ "$1" == "-q" ]] && {
|
|
|
|
quiet=-q
|
|
|
|
shift
|
|
|
|
}
|
2009-10-25 09:32:04 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# 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
|
|
|
|
|
|
|
|
[[ -z $2 ]] && usage
|
|
|
|
user=$1
|
|
|
|
host=$2
|
|
|
|
port=22
|
|
|
|
admin_name=$3
|
|
|
|
# but if the 3rd arg is a number, that's a port number, and the 4th arg is
|
|
|
|
# the admin_name
|
2009-11-18 10:07:04 +01:00
|
|
|
if echo $3 | perl -lne 'exit 1 unless /^[0-9]+$/'
|
2009-11-06 04:29:32 +01:00
|
|
|
then
|
|
|
|
port=$3
|
|
|
|
admin_name=$4
|
|
|
|
fi
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
echo $user | perl -lne 'exit 1 if /[^a-zA-Z0-9._-]/' ||
|
|
|
|
die "user '$user' invalid"
|
2009-11-26 07:43:42 +01:00
|
|
|
[[ "$user" == "root" ]] && die I refuse to install to root
|
2009-11-18 10:07:04 +01:00
|
|
|
echo $admin_name | perl -lne 'exit 1 if /[^a-zA-Z0-9._-]/' ||
|
|
|
|
die "admin_name '$admin_name' invalid"
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: make sure you're in the gitolite directory, at the top level.
|
|
|
|
# The following files should all be visible:
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2010-02-09 15:07:37 +01:00
|
|
|
ls hooks/gitolite-admin/post-update \
|
|
|
|
hooks/common/update \
|
2009-11-13 00:33:09 +01:00
|
|
|
src/gitolite.pm \
|
|
|
|
src/gl-install \
|
|
|
|
src/gl-auth-command \
|
|
|
|
src/gl-compile-conf \
|
|
|
|
conf/example.conf \
|
2009-11-06 04:29:32 +01:00
|
|
|
conf/example.gitolite.rc >/dev/null ||
|
|
|
|
die "cant find at least some files in gitolite sources/config; aborting"
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: make sure you have password-less (pubkey) auth on the server.
|
|
|
|
# That is, running "ssh git@server" should log in straight away, without
|
|
|
|
# asking for a password
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2010-04-16 09:19:07 +02:00
|
|
|
[[ $port -ne 22 ]] && p_port="-p $port"
|
|
|
|
ssh $p_port -o PasswordAuthentication=no $user@$host true ||
|
2009-11-06 04:29:32 +01:00
|
|
|
die "pubkey access didn't work; please set it up using 'ssh-copy-id' or something"
|
|
|
|
}
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# version info
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
version_info() {
|
2009-10-28 06:27:38 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: if needed, make a note of the version you are upgrading from, and to
|
2009-10-28 06:27:38 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# record which version is being sent across; we assume it's HEAD
|
2010-02-10 08:05:01 +01:00
|
|
|
git describe --tags --long HEAD 2>/dev/null > conf/VERSION || echo '(unknown)' > conf/VERSION
|
2009-10-28 06:27:38 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# what was the old version there?
|
2009-12-22 09:57:40 +01:00
|
|
|
export upgrade_details="you are upgrading \
|
2010-04-16 09:19:07 +02:00
|
|
|
$(ssh $p_port $user@$host cat gitolite-install/conf/VERSION 2>/dev/null || echo '(or installing first-time)' ) \
|
2010-02-10 08:05:01 +01:00
|
|
|
to $(cat conf/VERSION)"
|
2009-10-28 06:27:38 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "$upgrade_details" "$v_upgrade_details"
|
|
|
|
}
|
2009-10-28 06:27:38 +01:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# new keypair, ssh-config para; only on "install" (not upgrade)
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
setup_local_ssh() {
|
2009-11-05 17:46:18 +01:00
|
|
|
|
|
|
|
# MANUAL: create a new key for you as a "gitolite user" (as opposed to you
|
|
|
|
# as the "gitolite admin" who needs to login to the server and get a
|
|
|
|
# command line). For example, "ssh-keygen -t rsa ~/.ssh/sitaram"; this
|
|
|
|
# would create two files in ~/.ssh (sitaram and sitaram.pub)
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "setting up keypair..." "$v_setting_up_keypair"
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
if [[ -f "$HOME/.ssh/$admin_name.pub" ]]
|
2009-11-05 17:46:18 +01:00
|
|
|
then
|
2009-11-26 07:43:42 +01:00
|
|
|
prompt "" "$v_reuse_pubkey"
|
2009-11-05 17:46:18 +01:00
|
|
|
else
|
2009-11-18 10:07:04 +01:00
|
|
|
ssh-keygen -t rsa -f "$HOME/.ssh/$admin_name" || die "ssh-keygen failed for some reason..."
|
2009-11-05 17:46:18 +01:00
|
|
|
fi
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# MANUAL: copy the pubkey created to the server, say to /tmp. This would
|
|
|
|
# be "scp ~/.ssh/sitaram.pub git@server:/tmp" (the script does this at a
|
|
|
|
# later stage, you do it now for convenience). Note: only the pubkey
|
|
|
|
# (sitaram.pub). Do NOT copy the ~/.ssh/sitaram file -- that is a private
|
|
|
|
# key!
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# MANUAL: if you're running ssh-agent (see if you have an environment
|
|
|
|
# variable called SSH_AGENT_PID in your "env"), you should add this new
|
|
|
|
# key. The command is "ssh-add ~/.ssh/sitaram"
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
if ssh-add -l &>/dev/null
|
|
|
|
then
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt " ...adding key to agent..." "$v_ssh_add"
|
2009-11-18 10:07:04 +01:00
|
|
|
ssh-add "$HOME/.ssh/$admin_name"
|
2009-11-05 17:46:18 +01:00
|
|
|
fi
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# MANUAL: you now need to add some lines to the end of your ~/.ssh/config
|
|
|
|
# file. If the file doesn't exist, create it. Make sure the file is
|
|
|
|
# "chmod 644".
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# The lines to be included look like this:
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# host gitolite
|
|
|
|
# user git
|
|
|
|
# hostname server
|
|
|
|
# port 22
|
|
|
|
# identityfile ~/.ssh/sitaram
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
echo "host gitolite
|
|
|
|
user $user
|
|
|
|
hostname $host
|
|
|
|
port $port
|
|
|
|
identityfile ~/.ssh/$admin_name" > $tmpgli/.gl-stanza
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
if grep 'host *gitolite' "$HOME/.ssh/config" &>/dev/null
|
2009-11-05 17:46:18 +01:00
|
|
|
then
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "found gitolite para in ~/.ssh/config; assuming it is correct..." "$v_found_para"
|
2009-11-05 17:46:18 +01:00
|
|
|
else
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "creating gitolite para in ~/.ssh/config..." "$v_creating_para"
|
2009-11-18 10:07:04 +01:00
|
|
|
cat $tmpgli/.gl-stanza >> "$HOME/.ssh/config"
|
2009-11-05 17:46:18 +01:00
|
|
|
# if the file didn't exist at all, it might have the wrong permissions
|
2009-11-18 10:07:04 +01:00
|
|
|
chmod 644 "$HOME/.ssh/config"
|
2009-11-05 17:46:18 +01:00
|
|
|
fi
|
|
|
|
}
|
2009-10-10 09:08:22 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
2009-11-05 17:46:18 +01:00
|
|
|
# server side
|
2009-10-10 09:08:22 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
copy_gl() {
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: copy the gitolite directories "src", "conf", and "doc" to the
|
|
|
|
# server, to a directory called (for example) "gitolite-install". You may
|
|
|
|
# have to create the directory first.
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2010-04-16 09:19:07 +02:00
|
|
|
ssh $p_port $user@$host mkdir -p gitolite-install
|
|
|
|
scp $quiet ${p_port/p/P} -p -r src conf doc hooks $user@$host:gitolite-install/
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# 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 side but that may be too much typing for manual use ;-)
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: cd to the "gitolite-install" directory where the sources are.
|
|
|
|
# Then copy conf/example.gitolite.rc as ~/.gitolite.rc and edit it if you
|
|
|
|
# wish to change any paths. Make a note of the GL_ADMINDIR and REPO_BASE
|
|
|
|
# paths; you will need them later
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "finding/creating gitolite rc..." "$v_edit_glrc"
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# lets try and get the file from there first
|
2010-04-16 09:19:07 +02:00
|
|
|
if scp ${p_port/p/P} $user@$host:.gitolite.rc $tmpgli &>/dev/null
|
2009-10-13 06:32:45 +02:00
|
|
|
then
|
2009-11-06 04:29:32 +01:00
|
|
|
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..."
|
2010-01-14 10:44:40 +01:00
|
|
|
< $tmpgli/.gitolite.rc perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' | sort > $tmpgli/glrc.old
|
|
|
|
< conf/example.gitolite.rc perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' | sort > $tmpgli/glrc.new
|
2010-01-25 10:06:02 +01:00
|
|
|
# msysgit doesn't have "comm". diff is not ideal for our purposes
|
|
|
|
# because we only care about differences in one direction, but we'll
|
|
|
|
# have to make do...
|
2010-01-27 15:04:37 +01:00
|
|
|
set +e
|
|
|
|
diff -u $tmpgli/glrc.old $tmpgli/glrc.new | grep '^+.*\$' > $tmpgli/glrc.comm13
|
|
|
|
set -e
|
2010-01-14 10:44:40 +01:00
|
|
|
if [[ ! -s $tmpgli/glrc.comm13 ]]
|
2009-11-06 04:29:32 +01:00
|
|
|
then
|
|
|
|
[[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} $tmpgli/.gitolite.rc
|
|
|
|
else
|
2010-01-14 10:44:40 +01:00
|
|
|
echo new variables found in rc file:
|
|
|
|
cat $tmpgli/glrc.comm13
|
|
|
|
echo
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: if you're upgrading, read the instructions below and
|
|
|
|
# manually make sure your final ~/.gitolite.rc has both your existing
|
|
|
|
# customisations as well as any new variables that the new version of
|
|
|
|
# gitolite has introduced
|
|
|
|
prompt "" "$v_upgrade_glrc"
|
|
|
|
${VISUAL:-${EDITOR:-vi}} conf/example.gitolite.rc $tmpgli/.gitolite.rc
|
|
|
|
fi
|
2009-10-13 06:46:23 +02:00
|
|
|
else
|
2009-11-06 04:29:32 +01:00
|
|
|
cp conf/example.gitolite.rc $tmpgli/.gitolite.rc
|
|
|
|
[[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} $tmpgli/.gitolite.rc
|
2009-10-13 06:32:45 +02:00
|
|
|
fi
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# copy the rc across
|
2010-04-16 09:19:07 +02:00
|
|
|
scp $quiet ${p_port/p/P} $tmpgli/.gitolite.rc $user@$host:
|
2009-11-06 04:29:32 +01:00
|
|
|
}
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
run_install() {
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
prompt "installing/upgrading..." "$v_ignore_stuff"
|
2009-11-05 17:46:18 +01:00
|
|
|
|
2010-03-09 17:27:26 +01:00
|
|
|
# extract the GL_ADMINDIR, REPO_BASE and GIT_PATH locations
|
2010-04-16 09:19:07 +02:00
|
|
|
GL_ADMINDIR=$(ssh $p_port $user@$host "perl -e 'do \".gitolite.rc\"; print \$GL_ADMINDIR'")
|
|
|
|
REPO_BASE=$( ssh $p_port $user@$host "perl -e 'do \".gitolite.rc\"; print \$REPO_BASE'")
|
|
|
|
GIT_PATH=$( ssh $p_port $user@$host "perl -e 'do \".gitolite.rc\"; print \$GIT_PATH'")
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# determine if this is an upgrade; we decide based on whether a file
|
|
|
|
# called $GL_ADMINDIR/conf/gitolite.conf exists on the remote side. We
|
|
|
|
# can't do this till we know the correct value for GL_ADMINDIR
|
|
|
|
upgrade=0
|
2010-04-16 09:19:07 +02:00
|
|
|
if ssh $p_port $user@$host cat $GL_ADMINDIR/conf/gitolite.conf &> /dev/null
|
2009-11-06 04:29:32 +01:00
|
|
|
then
|
|
|
|
upgrade=1
|
2010-04-16 09:19:07 +02:00
|
|
|
ssh $p_port $user@$host cat $GL_ADMINDIR/conf/gitolite.conf 2> /dev/null | grep '@SHELL' &&
|
2010-01-14 10:44:40 +01:00
|
|
|
prompt "" "$v_at_shell_bwi"
|
2009-11-06 04:29:32 +01:00
|
|
|
[[ -n $admin_name ]] && echo -e "\n *** WARNING ***: looks like an upgrade... ignoring argument '$admin_name'"
|
|
|
|
else
|
|
|
|
[[ -z $admin_name ]] && die " *** ERROR ***: doesn't look like an upgrade, so I need a name for the admin"
|
|
|
|
fi
|
2009-10-14 07:40:06 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: still in the "gitolite-install" directory? Good. Run
|
2009-11-13 00:33:09 +01:00
|
|
|
# "src/gl-install"
|
2009-11-05 17:46:18 +01:00
|
|
|
|
2010-04-16 09:19:07 +02:00
|
|
|
ssh $p_port $user@$host "cd gitolite-install; src/gl-install $quiet"
|
2009-10-29 17:42:29 +01:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: if you're upgrading, run "src/gl-compile-conf" and you're done!
|
|
|
|
# -- ignore the rest of this file for the purposes of an upgrade
|
2009-10-29 17:42:29 +01:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
}
|
2009-10-14 07:40:06 +02:00
|
|
|
|
2009-11-05 17:46:18 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# from here on it's install only
|
|
|
|
# ----------------------------------------------------------------------
|
2009-10-14 07:40:06 +02:00
|
|
|
|
2009-10-11 05:01:59 +02:00
|
|
|
# MANUAL: setup the initial config file. Edit $GL_ADMINDIR/conf/gitolite.conf
|
|
|
|
# and add at least the following lines to it:
|
|
|
|
|
|
|
|
# repo gitolite-admin
|
|
|
|
# RW+ = sitaram
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
initial_conf_key() {
|
|
|
|
echo "#gitolite conf
|
2009-10-14 07:40:06 +02:00
|
|
|
# please see conf/example.conf for details on syntax and features
|
2009-10-10 09:08:22 +02:00
|
|
|
|
|
|
|
repo gitolite-admin
|
|
|
|
RW+ = $admin_name
|
|
|
|
|
|
|
|
repo testing
|
|
|
|
RW+ = @all
|
|
|
|
|
2009-10-30 13:13:26 +01:00
|
|
|
" > $tmpgli/gitolite.conf
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# send the config and the key to the remote
|
2010-04-16 09:19:07 +02:00
|
|
|
scp $quiet ${p_port/p/P} $tmpgli/gitolite.conf $user@$host:$GL_ADMINDIR/conf/
|
|
|
|
scp $quiet ${p_port/p/P} "$HOME/.ssh/$admin_name.pub" $user@$host:$GL_ADMINDIR/keydir
|
2009-11-06 04:29:32 +01:00
|
|
|
}
|
2009-10-10 09:08:22 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# hey lets go the whole hog on this; setup push-to-admin!
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
setup_pta() {
|
|
|
|
|
|
|
|
# MANUAL: you have to now make the first commit in the admin repo. This
|
|
|
|
# is a little more complex, so read carefully and substitute the correct
|
|
|
|
# paths. What you have to do is:
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# cd $REPO_BASE/gitolite-admin.git
|
|
|
|
# GIT_WORK_TREE=$GL_ADMINDIR git add conf/gitolite.conf keydir
|
|
|
|
# GIT_WORK_TREE=$GL_ADMINDIR git commit -am start
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# Substitute $GL_ADMINDIR and $REPO_BASE appropriately. Note there is no
|
|
|
|
# space around the "=" in the second and third lines.
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
echo "cd $REPO_BASE/gitolite-admin.git
|
2010-03-26 16:59:26 +01:00
|
|
|
PATH=\$PATH:$GIT_PATH
|
2009-10-10 09:08:22 +02:00
|
|
|
GIT_WORK_TREE=$GL_ADMINDIR git add conf/gitolite.conf keydir
|
2010-03-09 17:37:57 +01:00
|
|
|
GIT_WORK_TREE=$GL_ADMINDIR git diff --cached --quiet 2>/dev/null || GIT_WORK_TREE=$GL_ADMINDIR git commit -am start
|
2010-04-16 09:19:07 +02:00
|
|
|
" | ssh $p_port $user@$host
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: now that the admin repo is created, you have to set the hooks
|
|
|
|
# properly. The install program does this. So cd back to the
|
2009-11-13 00:33:09 +01:00
|
|
|
# "gitolite-install" directory and run "src/gl-install"
|
2009-11-06 04:29:32 +01:00
|
|
|
|
2010-04-16 09:19:07 +02:00
|
|
|
ssh $p_port $user@$host "cd gitolite-install; src/gl-install $quiet"
|
2009-11-06 04:29:32 +01:00
|
|
|
|
|
|
|
# MANUAL: you're done! Log out of the server, come back to your
|
|
|
|
# workstation, and clone the admin repo using "git clone
|
2009-11-22 05:51:22 +01:00
|
|
|
# gitolite:gitolite-admin", or pull once again if you already have a
|
2009-11-06 04:29:32 +01:00
|
|
|
# clone
|
2009-11-22 06:12:32 +01:00
|
|
|
}
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-22 06:12:32 +01:00
|
|
|
clone_it()
|
|
|
|
{
|
2009-11-06 04:29:32 +01:00
|
|
|
cleanup
|
2009-11-18 10:07:04 +01:00
|
|
|
cd "$HOME"
|
2009-11-22 06:12:32 +01:00
|
|
|
if [[ -d gitolite-admin ]]
|
|
|
|
then
|
|
|
|
echo $HOME/gitolite-admin exists, skipping clone step...
|
|
|
|
else
|
|
|
|
prompt "cloning gitolite-admin repo..." "$v_cloning"
|
|
|
|
git clone gitolite:gitolite-admin
|
|
|
|
fi
|
2009-10-14 07:40:06 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
# MANUAL: be sure to read the message below; this applies to you too...
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo ---------------------------------------------------------------
|
2009-11-22 06:12:32 +01:00
|
|
|
eval "echo \"$v_done\""
|
2009-11-06 04:29:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# prompt strings
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
v_upgrade_details="
|
|
|
|
\$upgrade_details
|
|
|
|
|
|
|
|
Note: getting '(unknown)' for the 'from' version should only happen once.
|
|
|
|
Getting '(unknown)' for the 'to' version means you are probably installing
|
|
|
|
from a tar file dump, not a real clone. This is not an error but it's nice to
|
|
|
|
have those version numbers in case you need support. Try and install from a
|
|
|
|
clone
|
|
|
|
"
|
|
|
|
|
|
|
|
v_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
|
|
|
|
passphrase or hit enter for none. I recommend not having a passphrase for
|
|
|
|
now, *especially* if you do not have a passphrase for the key which you are
|
|
|
|
already using to get server access!
|
|
|
|
|
|
|
|
Add one using 'ssh-keygen -p' after all the setup is done and you've
|
|
|
|
successfully cloned and pushed the gitolite-admin repo. After that, install
|
|
|
|
'keychain' or something similar, and add the following command to your bashrc
|
|
|
|
(since this is a non-default key)
|
|
|
|
|
2009-11-18 10:07:04 +01:00
|
|
|
ssh-add "\\\$HOME/.ssh/\$admin_name"
|
2009-11-06 04:29:32 +01:00
|
|
|
|
|
|
|
This makes using passphrases very convenient.
|
|
|
|
"
|
|
|
|
|
|
|
|
v_reuse_pubkey="
|
2009-11-26 07:43:42 +01:00
|
|
|
Hmmm... pubkey \$HOME/.ssh/\$admin_name.pub exists; should I just (re-)use it?
|
|
|
|
|
|
|
|
IMPORTANT: once the install completes, *this* key can no longer be used to get
|
|
|
|
a command line on the server -- it will be used by gitolite, for git access
|
|
|
|
only. If that is a problem, please ABORT now.
|
|
|
|
|
|
|
|
doc/6-ssh-troubleshooting.mkd will explain what is happening here, if you need
|
|
|
|
more info.
|
2009-11-06 04:29:32 +01:00
|
|
|
"
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
v_ssh_add="
|
|
|
|
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
|
|
|
|
you specified a passphrase in the previous step, you'll get asked for one
|
|
|
|
now -- type in the same one.
|
|
|
|
"
|
|
|
|
|
|
|
|
v_found_para="
|
|
|
|
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 that
|
|
|
|
paragraph (that line and the following few lines), Ctrl-C, and rerun.
|
|
|
|
|
|
|
|
In case you want to check right now (from another terminal) if they're
|
|
|
|
correct, here's what they are *supposed* to look like:
|
|
|
|
|
|
|
|
\$(cat \$tmpgli/.gl-stanza)
|
|
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
v_creating_para="
|
|
|
|
creating settings for your gitolite access in \$HOME/.ssh/config;
|
|
|
|
these are the lines that will be appended to your ~/.ssh/config:
|
|
|
|
|
|
|
|
\$(cat \$tmpgli/.gl-stanza)
|
|
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
v_edit_glrc="
|
|
|
|
the gitolite rc file needs to be edited by hand. The defaults 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
|
|
|
|
understand what is what -- the rc file's documentation is inline.
|
|
|
|
|
|
|
|
Please remember this file will actually be copied to the server, and that all
|
|
|
|
the paths etc. represent paths on the server!
|
|
|
|
"
|
|
|
|
|
|
|
|
v_upgrade_glrc="
|
|
|
|
looks like you're upgrading, and there are some new rc variables that this
|
|
|
|
version is expecting that your old rc file doesn't have.
|
|
|
|
|
2010-01-25 10:06:02 +01:00
|
|
|
I'm going to run your \\\$EDITOR with two filenames. The first is the example
|
2009-11-06 04:29:32 +01:00
|
|
|
file from this gitolite version. It will have a block (code and comments) for
|
|
|
|
each of the variables shown above with a '+' sign.
|
|
|
|
|
|
|
|
The second is your current rc file, the destination. Copy those lines into
|
|
|
|
this file, preferably *with* the surrounding comments (for clarity) and save
|
|
|
|
it.
|
|
|
|
|
|
|
|
This is necessary; please dont skip this!
|
|
|
|
|
2010-01-25 10:06:02 +01:00
|
|
|
[It's upto you to figure out how your \\\$EDITOR handles 2 filename arguments,
|
2009-11-06 04:29:32 +01:00
|
|
|
switch between them, copy lines, etc ;-)]
|
|
|
|
"
|
|
|
|
|
|
|
|
v_ignore_stuff="
|
|
|
|
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 for a manual
|
|
|
|
install, not this one...
|
|
|
|
"
|
|
|
|
|
2010-01-14 10:44:40 +01:00
|
|
|
v_at_shell_bwi="
|
|
|
|
you are using the @SHELL feature in your gitolite config. This feature has
|
|
|
|
now changed in a backward incompatible way; see doc/6-ssh-troubleshooting.mkd
|
|
|
|
for information on migrating this to the new syntax.
|
|
|
|
|
|
|
|
DO NOT hit enter unless you have understood that information and properly
|
|
|
|
migrated your setup, or you are sure you have shell access to the server
|
|
|
|
through some other means than the $admin_name key.
|
|
|
|
|
|
|
|
"
|
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
v_done="
|
|
|
|
done!
|
|
|
|
|
2010-04-21 21:42:59 +02:00
|
|
|
IMPORTANT NOTE -- PLEASE READ!!!
|
2010-04-29 10:58:03 +02:00
|
|
|
*Your* URL for cloning any repo from this server will be
|
2009-11-22 06:12:32 +01:00
|
|
|
gitolite:reponame.git
|
2010-03-07 15:01:21 +01:00
|
|
|
|
2009-11-22 06:12:32 +01:00
|
|
|
*Other* users you set up will have to use
|
|
|
|
\$user@\$host:reponame.git
|
2010-03-07 15:01:21 +01:00
|
|
|
However, if your server uses a non-standard ssh port, they should use
|
|
|
|
ssh://\$user@\$host:\$port/reponame.git
|
2009-11-06 04:29:32 +01:00
|
|
|
|
2009-11-22 06:12:32 +01:00
|
|
|
If this is your first time installing gitolite, please also:
|
|
|
|
tail -31 \$0
|
|
|
|
for next steps.
|
2009-11-06 04:29:32 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
v_cloning="
|
|
|
|
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 you can move
|
|
|
|
it elsewhere later if you wish to.
|
|
|
|
"
|
2009-10-11 05:01:59 +02:00
|
|
|
|
2009-11-06 04:29:32 +01:00
|
|
|
tail="
|
2010-02-26 02:43:19 +01:00
|
|
|
NOTE: All the below stuff is on your *workstation*. You should not, normally,
|
2009-11-26 07:43:42 +01:00
|
|
|
have to do anything directly on your server to administer/use gitolite.
|
2009-10-29 17:42:29 +01:00
|
|
|
|
2009-11-26 07:43:42 +01:00
|
|
|
The admin repo is currently cloned at ~/gitolite-admin. You can reclone it
|
|
|
|
anywhere else if you wish. To administer gitolite, make changes to the config
|
|
|
|
file (conf/gitolite.conf) and/or the pubkeys (in subdirectory 'keydir') in any
|
2009-10-29 17:42:29 +01:00
|
|
|
clone, then git add, git commit, and git push.
|
|
|
|
|
2010-02-26 02:43:19 +01:00
|
|
|
ADDING REPOS: Do NOT add repos manually on the server. Edit the config file
|
|
|
|
to give *some* user access to the repo. When you push, an empty repo will be
|
|
|
|
created on the server.
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-10-29 17:42:29 +01:00
|
|
|
ADDING USERS: copy their pubkey as keydir/<username>.pub, add it, commit and
|
|
|
|
push.
|
2009-10-10 09:08:22 +02:00
|
|
|
|
2009-10-29 17:42:29 +01:00
|
|
|
CONFIG FILE FORMAT: see comments in conf/example.conf in the gitolite source.
|
|
|
|
|
|
|
|
SSH MAGIC: Remember you (the admin) now have *two* keys to access the server
|
|
|
|
hosting your gitolite setup -- one to get you a command line, and one to get
|
2009-11-03 09:31:03 +01:00
|
|
|
you gitolite access; see doc/6-ssh-troubleshooting.mkd. If you're not using
|
2009-12-02 07:19:58 +01:00
|
|
|
keychain or some such software, you may have to run an 'ssh-add' command to
|
|
|
|
add that key each time you log in.
|
2009-10-29 17:42:29 +01:00
|
|
|
|
2009-12-02 07:19:58 +01:00
|
|
|
URLS: *Your* URL for cloning any repo on this server is different from the
|
|
|
|
url that the *other* users have to use. The easy install command should tell
|
|
|
|
you what these URLs look like, at the end of each successful run. Feel free
|
|
|
|
to re-run easy install again (using the same arguments) if you missed it.
|
2009-10-29 17:42:29 +01:00
|
|
|
|
2009-12-02 07:19:58 +01:00
|
|
|
UPGRADING GITOLITE: just pull a fresh clone from github, and run the same easy
|
|
|
|
install command as before, with the same arguments.
|
2009-10-29 17:42:29 +01:00
|
|
|
"
|