summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2018-01-21 01:51:27 -0800
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2018-01-21 02:09:11 -0800
commit1e0fde1688055de6ddd42da658af43546ee90871 (patch)
tree194653974a4916b5e843b6f95af93c91b677905b
parent5b8fd3bd5a45bcaf0d57c240c2df05b2dac1f255 (diff)
downloadpiny-code-1e0fde1688055de6ddd42da658af43546ee90871.tar.gz
piny-code-1e0fde1688055de6ddd42da658af43546ee90871.zip
Piny::Repo: Initial read-only repository support.
Not all systems want us to manage git repositories: we can still provide ikiwiki/apache support for existing read-only repositories. This would probably be better done with some sort of configuration variable, but a simple access() W_OK writability check will have to do for now.
-rw-r--r--libpiny/lib/Piny/Repo.pm11
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;