summaryrefslogtreecommitdiff
path: root/libpiny/lib/Piny/Repo.pm
diff options
context:
space:
mode:
Diffstat (limited to 'libpiny/lib/Piny/Repo.pm')
-rw-r--r--libpiny/lib/Piny/Repo.pm20
1 files changed, 15 insertions, 5 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index 306b3a8..335843e 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -203,12 +203,15 @@ sub has_access {
sub rebuild {
my ( $s ) = @_;
- unless( getgrnam("git-" . $s->name ); ) {
- system( "/usr/sbin/addgroup", "--quiet", "git-$s->name" ) and die "Could not create repo group!";
+ unless( getgrnam("git-" . $s->name ) ) {
+ system( "/usr/sbin/addgroup", "--quiet", "git-" . $s->name ) and die "Could not create repo group!";
+ system( "/usr/sbin/adduser", "--quiet", $s->owner->name, "git-" . $s->name ) and die "Could not add you to the repo group!";
+ system( "/usr/sbin/adduser", "--quiet", "iki-" . $s->name, "git-" . $s->name ) and print "...But that's probably okay.\n";
};
- unless( getpwname("iki-" . $s->name ); ) {
- system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $s->name, "iki-$s->name" ) and die "Could not create ikiwiki user!";
+ unless( getpwnam("iki-" . $s->name ) ) {
+ system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $s->name, "iki-" . $s->name ) and die "Could not create ikiwiki user!";
+ system( "/usr/sbin/adduser", "--quiet", "iki-" . $s->name, "git-" . $s->name ) and die "Could not add ikiwiki user to the repo group!";
};
my $ikiuser = Piny::User::IkiWiki->new( "name" => "iki-" . $s->name );
@@ -234,7 +237,14 @@ sub rebuild {
print SETUP $s->ikiwiki_setup;
close( SETUP ) or die "Could not close new ikiwiki setup file: $!";
- system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $s->ikiwiki_srcdir, $s->ikiwiki_destdir, $s->secure_path ) and die "Could not change ownership of ikiwiki directories!";
+ unless( -d $s->ikiwiki_srcdir ) {
+ system( "/usr/bin/git", "clone", "--quiet", $s->path, $s->ikiwiki_srcdir ) and die "Could not clone repo to ikiwiki srcdir!";
+ };
+
+ foreach( $ikiuser->name, $s->ikiwiki_srcdir, $s->ikiwiki_destdir, $s->secure_path ) {
+ unless( -d $_ ) { mkdir( $_ ) };
+ system( "/bin/chown", "-R", $ikiuser->name . ".", $_ ) and die "Could not change ownership of ikiwiki directories!";
+ };
open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $s->name ) or die "Could not create wikilist.d file: $!";
print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $s->name . ".setup\n";