summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpiny/lib/Piny/Repo.pm76
1 files changed, 3 insertions, 73 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index cfe7b1d..f4154da 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -368,6 +368,7 @@ sub all_repos {
return @ret;
};
+# Only sets up needed data; ->rebuild takes care of the rest.
sub create {
my ( $class, $name, $description ) = @_;
@@ -380,85 +381,14 @@ sub create {
mkdir( $repo->path ) or die "The repo $name appears to already exist! ($!)";
- system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $name, "iki-" . $repo->shortname ) and die "Could not create ikiwiki user!";
-
- my $ikiuser = Piny::User::IkiWiki->new( "name" => "iki-" . $repo->shortname );
-
- system( "/usr/sbin/addgroup", "--quiet", "git-" . $repo->shortname ) and die "Could not create repo group!";
-
- my $group = Piny::Group->new( "name" => "git-" . $repo->shortname );
-
- system( "/usr/sbin/adduser", "--quiet", $user->name, $group->name ) and die "Could not add you to the repo group!";
- system( "/usr/sbin/adduser", "--quiet", $ikiuser->name, $group->name ) and die "Could not add ikiwiki user to the repo group!";
-
$ENV{"GIT_DIR"} = $repo->path;
system( "/usr/bin/git", "init", "--template=/srv/git-template.git", "--quiet", "--shared" ) and die "Could not initialize git repo!";
-
- foreach( "git-daemon-export-ok", "packed-refs" ) {
- unless( -e $repo->path . "/" . $_ ) {
- open( TOUCH, ">", $repo->path . "/" . $_ ) or die "Could not touch $_ for repo: $!";
- close( TOUCH );
- };
- };
-
- foreach( "info", "logs" ) {
- ( -e $repo->path . "/" . $_ ) or mkdir( $repo->path . "/" . $_ ) or die "Could not mkdir $_ for repo: $!";
- };
-
- foreach( "branches", "description", "HEAD", "info", "logs", "objects", "packed-refs", "refs" ) {
- system( "/bin/chown", "-R", $user->name . "." . $group->name, $repo->path . "/" . $_ ) and die "Could not change ownership of $_ for repo: $!";
- };
-
- chown( 0, 0, $repo->path, $repo->path . "/config" ) or die "Could not change ownership of git dir!";
-
- system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $repo->path . "/hooks" ) and die "Could not change ownership of git hooks!";
-
- system( "/usr/bin/git", "config", "gitweb.owner", $repo->owner->email->address ) and die "Could not git config gitweb.owner!";
+ system( "/bin/chown", "-R", $user->name, $repo->path . "/objects" ) and die "Could not change ownership of $_ for repo: $!";
delete $ENV{"GIT_DIR"};
$repo->description( $description );
- open( SETUP, ">", "/etc/ikiwiki/piny/" . $repo->name . ".setup" ) or die "Could not open new ikiwiki setup file: $!";
- print SETUP $repo->ikiwiki_setup;
- close( SETUP ) or die "Could not close new ikiwiki setup file: $!";
-
- system( "/usr/bin/git", "clone", "--quiet", $repo->path, $repo->ikiwiki_srcdir ) and die "Could not clone repo to ikiwiki srcdir!";
-
- mkdir( $repo->ikiwiki_destdir ) or die "Could not create ikiwiki destdir: $!";
- mkdir( $repo->secure_path ) or die "Could not create secure dir: $!";
-
- system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $repo->ikiwiki_srcdir, $repo->ikiwiki_destdir, $repo->secure_path ) and die "Could not change ownership of ikiwiki directories!";
-
- open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $repo->name ) or die "Could not create wikilist.d file: $!";
- print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $repo->name . ".setup\n";
- close( WIKILIST ) or die "Could not close wikilist.d file: $!";
-
- my $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
- $temp->unlink_on_destroy( 0 );
-
- my $dh = IO::Dir->new( "/etc/ikiwiki/wikilist.d" ) or die "Could not open wikilist.d directory: $!";
- while ( defined ( my $entry = $dh->read ) ) {
- next if ( $entry =~ /^\./ );
- open( FILE, "<", "/etc/ikiwiki/wikilist.d/" . $entry ) or die "Could not open wikilist.d entry $entry: $!";
- print $temp <FILE>;
- close( FILE ) or die "Could not close wikilist.d entry $entry: $!";
- };
-
- $temp->close or die "Could not close new wikilist: $!";
-
- chmod( 00644, $temp->filename ) or die "Could not fix mode of new wikilist: $!";
-
- rename( $temp->filename, "/etc/ikiwiki/wikilist" ) or die "Could not rename over old wikilist: $!";
-
- system( "/usr/bin/sudo", "-u", $ikiuser->name, "/usr/bin/ikiwiki", "--setup", "/etc/ikiwiki/piny/" . $repo->name . ".setup" ) and die "Could not do initial compile of ikiwiki!";
-
- open( APACHE, ">", "/etc/apache2/piny-available/" . $repo->name ) or die "Could not open new apache config: $!";
- print APACHE $repo->apache_config;
- close( APACHE ) or die "Could not close new apache config: $!";
-
- symlink( "/etc/apache2/piny-available/" . $repo->name, "/etc/apache2/piny-enabled/" . $repo->name ) or die "Could not symlink apache config: $!";
-
- system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
+ $repo->rebuild;
return $repo;
};