diff options
Diffstat (limited to 'libpiny/lib/Piny')
-rw-r--r-- | libpiny/lib/Piny/Repo.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index ffdd9fb..d59ad7e 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -16,6 +16,7 @@ use File::Find qw( find ); use File::Temp qw( ); use IO::Dir qw( ); use Math::GMP qw( ); +use POSIX qw( ); use IkiWiki::FakeSetup qw( readSetup writeSetup ); @@ -227,7 +228,11 @@ sub has_access { sub rebuild { my ( $s ) = @_; - $s->rebuild_git; + if( POSIX::access( $s->path, &POSIX::W_OK ) ){ + $s->rebuild_git; + } else { + warn "Read-only git repository detected. Skipping git rebuild."; + }; $s->rebuild_apache; $s->destroy_ikiwiki; @@ -342,12 +347,12 @@ sub rebuild_ikiwiki { unless( getpwnam("iki-" . $s->shortname ) ) { system( "/usr/sbin/adduser", "--quiet", "--system", "--group", "--gecos", $s->shortname, "iki-" . $s->shortname ) and die "Could not create ikiwiki user!"; - system( "/usr/sbin/adduser", "--quiet", "iki-" . $s->shortname, "git-" . $s->shortname ) and die "Could not add ikiwiki user to the repo group!"; + system( "/usr/sbin/adduser", "--quiet", "iki-" . $s->shortname, "git-" . $s->shortname ) and warn "Could not add ikiwiki user to the repo group!"; }; my $ikiuser = Piny::User::IkiWiki->new( "name" => "iki-" . $s->shortname ); - system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $s->path . "/hooks" ) and die "Could not change ownership of git hooks!"; + system( "/bin/chown", $ikiuser->name . "." . $ikiuser->name, $s->path . "/hooks" ) and warn "Could not change ownership of git hooks!"; open( SETUP, ">", "/etc/ikiwiki/piny/" . $s->name . ".setup" ) or die "Could not open new ikiwiki setup file: $!"; print SETUP $s->ikiwiki_setup; |