diff --git a/conf/example.gitolite.rc b/conf/example.gitolite.rc index 44413a0..72acc79 100644 --- a/conf/example.gitolite.rc +++ b/conf/example.gitolite.rc @@ -1,20 +1,38 @@ -# this is meant to be pulled into a perl program using "do" +# default paths for gitolite + +# please read comments before editing + +# this file is meant to be pulled into a perl program using "do" or "require". + +# You do NOT need to know perl to edit the paths; it should be fairly +# self-explanatory + +# -------------------------------------- + +# this is where the repos go. If you provide a relative path (not starting +# with "/"), it's relative to your $HOME. You may want to put in something +# like "/bigdisk" or whatever if your $HOME is too small for the repos, for +# example -# base directory for all the repos (absolute, or relative to $HOME) $REPO_BASE="repositories"; +# -------------------------------------- + +# I see no reason anyone may want to change the gitolite admin directory, but +# feel free to do so + # gitolite admin directory, files, etc $GL_ADMINDIR=$ENV{HOME} . "/.gitolite"; # -------------------------------------- -# the ones below can be left as they are, unless for some reason you want them -# elsewhere +# I see even less reason to change these, since they're all relative to the +# gitolite admin directory above, but hey it's *your* system... $GL_CONF="$GL_ADMINDIR/conf/gitolite.conf"; $GL_KEYDIR="$GL_ADMINDIR/keydir"; $GL_CONF_COMPILED="$GL_ADMINDIR/conf/gitolite.conf-compiled.pm"; # -------------------------------------- -# this should be the last line in this file, per perl rules +# per perl rules, this should be the last line in such a file: 1; diff --git a/src/install.pl b/src/install.pl new file mode 100755 index 0000000..73fb118 --- /dev/null +++ b/src/install.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +our $REPO_BASE; +our $GL_ADMINDIR; +our $GL_CONF; + +# wrapper around mkdir; it's not an error if the directory exists, but it is +# an error if it doesn't exist and we can't create it +sub wrap_mkdir +{ + my $dir = shift; + -d $dir or mkdir($dir) or die "mkdir $dir failed: $!\n"; +} + +# the only path that is *fixed* (can't be changed without changing all 3 +# programs) is ~/.gitolite.rc + +my $glrc = $ENV{HOME} . "/.gitolite.rc"; +unless (-f $glrc) { + # doesn't exist. Copy it across, tell user to edit it and come back + system("cp conf/example.gitolite.rc $glrc"); + print STDERR "created $glrc\n"; + print STDERR "please edit it, set the paths as you like, and rerun this script\n"; + exit; +} + +# ok now $glrc exists; read it to get the other paths +unless (my $ret = do $glrc) +{ + die "parse $glrc failed: $@" if $@; + die "couldn't do $glrc: $!" unless defined $ret; + die "couldn't run $glrc" unless $ret; +} + +# mkdir $REPO_BASE, $GL_ADMINDIR if they don't already exist +wrap_mkdir( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); +wrap_mkdir($GL_ADMINDIR); +# mkdir $GL_ADMINDIR's subdirs +for my $dir qw(conf doc keydir src) { + wrap_mkdir("$GL_ADMINDIR/$dir"); +} + +# "src" and "doc" will be overwritten on each install, but not conf +system("cp -R src doc $GL_ADMINDIR"); + +unless (-f $GL_CONF) { + system("cp conf/example.conf $GL_CONF"); + print STDERR <