From a26421a98e3336d447a5656bf9ae262b1de4d42f Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Fri, 12 Apr 2013 19:05:35 -0700 Subject: libpiny: making git path configurable (default: /srv/git) --- libpiny/lib/Piny/Config.pm | 1 + libpiny/lib/Piny/Repo.pm | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'libpiny/lib') diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm index bb72536..ec86955 100644 --- a/libpiny/lib/Piny/Config.pm +++ b/libpiny/lib/Piny/Config.pm @@ -256,6 +256,7 @@ sub tweakable { # Global tweakables, which only make sense in the global config file. tweakable "piny_adminemail" => "jrayhawk\@omgwallhack.org", 'Str', 'inhibit'; tweakable "piny_template" => undef, 'Maybe[PathDir]', 'inhibit'; +tweakable "piny_gitpath" => '/srv/git', 'PathDir'; # Repo-specific tweakables, in the repos' .git/config files. tweakable "piny_ikiwiki" => "true", 'GitBool'; diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index fe457cf..031558e 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -336,7 +336,7 @@ sub rebuild_apache { sub rebuild_ikiwiki { my ( $s ) = @_; - chdir( "/srv/git" ); # because git likes to chdir back to its original cwd for some dumb reason, which isn't guaranteed to work. + chdir( $s->config->piny_gitpath ); # because git likes to chdir back to its original cwd for some dumb reason, which isn't guaranteed to work. 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!"; @@ -464,7 +464,7 @@ sub _change_owner { sub all_repos { my ( $class, $dir ) = @_; - $dir = "/srv/git" unless defined $dir; + $dir = $s->config->piny_gitpath unless defined $dir; my @ret; @@ -492,7 +492,7 @@ sub create { mkdir( $repo->path ) or die "The repo $name appears to already exist! ($!)"; - chdir( "/srv/git" ); # so git-clone can do the work of resolving local repo names for us + chdir( $s->config->piny_gitpath ); # so git-clone can do the work of resolving local repo names for us if ( defined $remote ) { system( "/bin/chown", $user->name, $repo->path ) and die "Could not change ownership of repo path!"; # permissions are overridden later if ( system( "/usr/bin/sudo", "-H", "-u", $user->name, "/usr/bin/git", "clone", "--bare", "--no-hardlinks", "--quiet", $remote, $repo->path ) ) { # sudo -u $user needed in order to test user readability of whatever they want to clone. the mode o+rx should probably be masked off if we want private repos to stay private. @@ -577,7 +577,7 @@ sub _build_group { sub _build_path { my ( $s ) = @_; - return "/srv/git/" . $s->name . ".git"; + return $s->config->piny_gitpath . $s->name . ".git"; }; sub _build_description { -- cgit v1.2.3