#!/usr/bin/perl # INTERNAL COMMAND. NOT MEANT TO BE RUN BY THE USER DIRECTLY. use strict; use warnings; our ($REPO_BASE, $GL_ADMINDIR, $GL_CONF, $GIT_PATH, $GL_PACKAGE_CONF, $GL_PACKAGE_HOOKS); # setup quiet mode if asked; please do not use this when running manually open STDOUT, ">", "/dev/null" if (@ARGV and shift eq '-q'); # 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; if ( -d $dir ) { print "$dir already exists\n"; return; } mkdir($dir) or die "mkdir $dir failed: $!\n"; print "created $dir\n"; } # the common setup module is in the same directory as this running program is my $bindir = $0; $bindir =~ s/\/[^\/]+$//; require "$bindir/gitolite.pm"; # ask where the rc file is, get it, and "do" it &where_is_rc(); unless ($ENV{GL_RC}) { # doesn't exist. Copy it across, tell user to edit it and come back my $glrc = $ENV{HOME} . "/.gitolite.rc"; if ($GL_PACKAGE_CONF) { system("cp $GL_PACKAGE_CONF/example.gitolite.rc $glrc"); } else { system("cp $bindir/../conf/example.gitolite.rc $glrc"); } print "created $glrc\n"; print "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n"; exit; } # ok now the rc file exists; read it to get the other paths die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC}; # add a custom path for git binaries, if specified $ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH; # mkdir $REPO_BASE, $GL_ADMINDIR if they don't already exist $ENV{GL_REPO_BASE_ABS} = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); wrap_mkdir($ENV{GL_REPO_BASE_ABS}); wrap_mkdir($GL_ADMINDIR); # mkdir $GL_ADMINDIR's subdirs for my $dir qw(conf doc keydir logs src hooks hooks/common hooks/gitolite-admin) { # some of them will stay empty; too lazy to fix right now ;-) wrap_mkdir("$GL_ADMINDIR/$dir"); } # "src" and "doc" will be overwritten on each install, but not conf if ($GL_PACKAGE_HOOKS) { system("cp -R -p $GL_PACKAGE_HOOKS $GL_ADMINDIR"); } else { system("cp -R -p $bindir/../src $bindir/../doc $bindir/../hooks $GL_ADMINDIR"); system("cp $bindir/../conf/VERSION $GL_ADMINDIR/conf"); } unless (-f $GL_CONF or $GL_PACKAGE_CONF) { print <