diff options
author | jrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu> | 2011-04-20 22:19:33 -0700 |
---|---|---|
committer | jrayhawk+piny.be@omgwallhack.org <jrayhawk@dev.piny.svcs.cs.pdx.edu> | 2011-04-20 22:19:33 -0700 |
commit | b5609ce3f6b3d40f1fc55e8bedc66e50fcf3f686 (patch) | |
tree | 4326f4c936ee326300d9412c288693f457d1ba51 /libpiny/lib | |
parent | f14aee049e7363e40dd817691aa8fb64c2f450e1 (diff) | |
download | piny-code-b5609ce3f6b3d40f1fc55e8bedc66e50fcf3f686.tar.gz piny-code-b5609ce3f6b3d40f1fc55e8bedc66e50fcf3f686.zip |
Robustifying rebuildrepo to tolerate foreign-created repositories somewhat better.
Diffstat (limited to 'libpiny/lib')
-rw-r--r-- | libpiny/lib/Piny/Repo.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index 17142ed..7818463 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -203,6 +203,17 @@ 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!"; + 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", "ikiwiki-" . $s->name, "git-" . $s->name ) and print "...But that's probably okay.\n"; + }; + + unless( getpwnam("ikiwiki-" . $s->name ) ) { + system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $s->name, "ikiwiki-" . $s->name ) and die "Could not create ikiwiki user!"; + system( "/usr/sbin/adduser", "--quiet", "ikiwiki-" . $s->name, "git-" . $s->name ) and die "Could not add ikiwiki user to the repo group!"; + }; + my $ikiuser = Piny::User::IkiWiki->new( "name" => "ikiwiki-" . $s->name ); foreach( "git-daemon-export-ok", "packed-refs" ) { @@ -210,7 +221,7 @@ sub rebuild { close( TOUCH ); }; - foreach( "info", "logs" ) { + foreach( "info", "logs", "branches" ) { (-e $s->path . "/" . $_) or mkdir( $s->path . "/" . $_ ) or die "Could not mkdir $_ for repo: $!"; }; @@ -226,7 +237,12 @@ 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!"; + 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"; |