2009-08-30 08:41:55 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2009-09-06 10:04:41 +02:00
|
|
|
our ($REPO_BASE, $GL_ADMINDIR, $GL_CONF);
|
2009-08-30 08:41:55 +02:00
|
|
|
|
|
|
|
# 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;
|
2009-09-10 15:35:07 +02:00
|
|
|
if ( -d $dir ) {
|
|
|
|
print STDERR "$dir already exists\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mkdir($dir) or die "mkdir $dir failed: $!\n";
|
|
|
|
print STDERR "created $dir\n";
|
2009-08-30 08:41:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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";
|
2009-09-10 15:35:07 +02:00
|
|
|
print STDERR "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n";
|
2009-08-30 08:41:55 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# ok now $glrc exists; read it to get the other paths
|
2009-09-01 16:06:00 +02:00
|
|
|
die "parse $glrc failed: " . ($! or $@) unless do $glrc;
|
2009-08-30 08:41:55 +02:00
|
|
|
|
|
|
|
# mkdir $REPO_BASE, $GL_ADMINDIR if they don't already exist
|
2009-09-06 10:04:41 +02:00
|
|
|
my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" );
|
|
|
|
wrap_mkdir($repo_base_abs);
|
2009-08-30 08:41:55 +02:00
|
|
|
wrap_mkdir($GL_ADMINDIR);
|
|
|
|
# mkdir $GL_ADMINDIR's subdirs
|
2009-09-06 10:04:41 +02:00
|
|
|
for my $dir qw(conf doc keydir logs src) {
|
2009-08-30 08:41:55 +02:00
|
|
|
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 <<EOF;
|
|
|
|
created $GL_CONF
|
|
|
|
please edit it, then run these two commands:
|
|
|
|
cd $GL_ADMINDIR
|
|
|
|
src/gl-compile-conf
|
|
|
|
(the "admin" document should help here...)
|
|
|
|
EOF
|
|
|
|
}
|
2009-09-01 17:03:19 +02:00
|
|
|
|
|
|
|
# finally, any potential changes to src/update-hook.pl must be propagated to
|
|
|
|
# all the repos' hook directories
|
2009-09-06 10:04:41 +02:00
|
|
|
chdir("$repo_base_abs") or die "chdir $repo_base_abs failed: $!\n";
|
|
|
|
for my $repo (`find . -type d -name "*.git"`) {
|
|
|
|
chomp ($repo);
|
|
|
|
system("cp $GL_ADMINDIR/src/update-hook.pl $repo/hooks/update");
|
|
|
|
chmod 0755, "$repo/hooks/update";
|
2009-09-01 17:03:19 +02:00
|
|
|
}
|