summaryrefslogtreecommitdiff
path: root/libpiny/lib/Piny/Repo.pm
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2011-12-30 23:40:19 -0800
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2011-12-30 23:40:19 -0800
commit431a4a4185784fef43eb1126a54abc226ccdc99b (patch)
tree39f814ccc9133b2f3434da83229105c1110c161d /libpiny/lib/Piny/Repo.pm
parent372b5f9a390116177870154ddfd3a36d5dcb8d32 (diff)
downloadpiny-code-431a4a4185784fef43eb1126a54abc226ccdc99b.tar.gz
piny-code-431a4a4185784fef43eb1126a54abc226ccdc99b.zip
Repo: Apache configs should really do things in the piny.ikiwiki=false case
Diffstat (limited to 'libpiny/lib/Piny/Repo.pm')
-rw-r--r--libpiny/lib/Piny/Repo.pm99
1 files changed, 57 insertions, 42 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index 774daf9..7362d4e 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -228,6 +228,7 @@ sub rebuild {
my ( $s ) = @_;
$s->rebuild_git;
+ $s->rebuild_apache;
$s->destroy_ikiwiki;
if ( $s->config->piny_ikiwiki =~ /^(1|true)$/ ) {
@@ -307,6 +308,31 @@ sub rebuild_git {
};
+sub rebuild_apache {
+
+ my ( $s ) = @_;
+
+ my $globaltemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ $globaltemp->unlink_on_destroy( 0 );
+ print $globaltemp $s->apache_global_config;
+ $globaltemp->close or die "Could not close new wikilist: $!";
+ rename( $globaltemp->filename, "/etc/apache2/piny/global/" . $s->name ) or die "Could not rename apache config: $!";
+
+ my $securetemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ $securetemp->unlink_on_destroy( 0 );
+ print $securetemp $s->apache_secure_config;
+ $securetemp->close or die "Could not close new wikilist: $!";
+ rename( $securetemp->filename, "/etc/apache2/piny/secure/" . $s->name ) or die "Could not rename apache config: $!";
+
+ my $wwwtemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ $wwwtemp->unlink_on_destroy( 0 );
+ print $wwwtemp $s->apache_www_config;
+ $wwwtemp->close or die "Could not close new wikilist: $!";
+ rename( $wwwtemp->filename, "/etc/apache2/piny/www/" . $s->name ) or die "Could not rename apache config: $!";
+
+ system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
+};
+
sub rebuild_ikiwiki {
my ( $s ) = @_;
@@ -345,26 +371,6 @@ sub rebuild_ikiwiki {
$s->rebuild_wikilist;
system( "/usr/bin/sudo", "-H", "-u", $ikiuser->name, "/usr/bin/ikiwiki", "--setup", "/etc/ikiwiki/piny/" . $s->name . ".setup" ) and die "Could not do initial compile of ikiwiki!";
-
- my $globaltemp = File::Temp->new( ) or die "Could not create temporary file: $!";
- $globaltemp->unlink_on_destroy( 0 );
- print $globaltemp $s->apache_global_config;
- $globaltemp->close or die "Could not close new wikilist: $!";
- rename( $globaltemp->filename, "/etc/apache2/piny/global/" . $s->name ) or die "Could not rename apache config: $!";
-
- my $securetemp = File::Temp->new( ) or die "Could not create temporary file: $!";
- $securetemp->unlink_on_destroy( 0 );
- print $securetemp $s->apache_secure_config;
- $securetemp->close or die "Could not close new wikilist: $!";
- rename( $securetemp->filename, "/etc/apache2/piny/secure/" . $s->name ) or die "Could not rename apache config: $!";
-
- my $wwwtemp = File::Temp->new( ) or die "Could not create temporary file: $!";
- $wwwtemp->unlink_on_destroy( 0 );
- print $wwwtemp $s->apache_www_config;
- $wwwtemp->close or die "Could not close new wikilist: $!";
- rename( $wwwtemp->filename, "/etc/apache2/piny/www/" . $s->name ) or die "Could not rename apache config: $!";
-
- system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
};
sub rebuild_wikilist {
@@ -390,6 +396,7 @@ sub destroy {
my ( $s ) = @_;
$s->destroy_ikiwiki;
+ $s->destroy_apache;
$s->destroy_git;
};
@@ -399,11 +406,9 @@ sub destroy_git {
system( "delgroup", $s->group->name );
};
-sub destroy_ikiwiki {
+sub destroy_apache {
my ( $s ) = @_;
- my $user = Piny::Environment->instance->user;
-
foreach( "/etc/apache2/piny/global/" . $s->name, "/etc/apache2/piny/secure/" . $s->name, "/etc/apache2/piny/www/" . $s->name, ) {
if ( -e $_ ) {
unlink( $_ );
@@ -411,6 +416,12 @@ sub destroy_ikiwiki {
};
system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
+};
+
+sub destroy_ikiwiki {
+ my ( $s ) = @_;
+
+ my $user = Piny::Environment->instance->user;
if ( -e "/etc/ikiwiki/wikilist.d/" . $s->name ) {
unlink( "/etc/ikiwiki/wikilist.d/" . $s->name );
@@ -784,39 +795,43 @@ sub _build_apache_global_config {
"<Directory " . $s->ikiwiki_destdir . ">\n AuthPAM_Enabled on\n AuthGROUP_Enabled on \n AuthPAM_FallThrough off\n AuthBasicAuthoritative off\n AuthType Basic\n AuthName \"User with access to " . $s->name . " repository needed.\"\n Require group " . $s->group->name . "\n</Directory>\n"
);
} else {
- die ( $s->config->core_sharedrepository . "is an unhandled value!" );
+ die ( $s->config->core_sharedrepository . " is an unhandled value!" );
};
};
sub _build_apache_secure_config {
my ( $s ) = @_;
- if ( $s->config->core_sharedrepository eq "0666" ) {
- return ( "Redirect /read/" . $s->name . " " . $s->ikiwiki_url . "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0664|all|everybody|world)$/ ) {
- return ( "Redirect /read/" . $s->name . " " . $s->ikiwiki_url . "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0660|true|1|group)$/ ) {
- return ( "Redirect /cgit/" . $s->name . " /auth/cgit/" . $s->name . "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0640|false|0)$/ ) {
- return ( "Redirect /cgit/" . $s->name . " /auth/cgit/" . $s->name . "\n" );
+ if ( $s->config->core_sharedrepository eq "0666" ) or ( $s->config->core_sharedrepository =~ /^(0664|all|everybody|world)$/ ) {
+ return ( "Redirect /read/" . $s->name . " " . $s->ikiwiki_url . "\n" );
+ } elsif ( $s->config->core_sharedrepository =~ /^(0660|true|1|group)$/ ) or ( $s->config->core_sharedrepository =~ /^(0640|false|0)$/ ) {
+ if ( $s->config->piny_ikiwiki =~ /^(1|true)$/ ) {
+ return ( "Redirect /cgit/" . $s->name . " /auth/cgit/" . $s->name . "\n" );
+ } elsif ( $s->config->piny_ikiwiki =~ /^(0|false)$/ ) {
+ return ( "Redirect /cgit/" . $s->name . " /auth/cgit/" . $s->name . "\nRedirect /read/" . $s->name . " /cgit/" . $s->name . "/tree\n" );
+ } else {
+ die ( $s->config->piny_ikiwiki . " is an unhandled value!" );
+ };
} else {
- die ( $s->config->core_sharedrepository . "is an unhandled value!" );
+ die ( $s->config->core_sharedrepository . " is an unhandled value!" );
};
};
sub _build_apache_www_config {
my ( $s ) = @_;
- if ( $s->config->core_sharedrepository eq "0666" ) {
- return ( "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0664|all|everybody|world)$/ ) {
- return ( "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0660|true|1|group)$/ ) {
- return ( "Redirect /" . $s->name . " " . $s->ikiwiki_url . "\n" );
- } elsif ( $s->config->core_sharedrepository =~ /^(0640|false|0)$/ ) {
- return ( "Redirect /" . $s->name . " " . $s->ikiwiki_url . "\n" );
+ if ( $s->config->core_sharedrepository eq "0666" ) or ( $s->config->core_sharedrepository =~ /^(0664|all|everybody|world)$/ ) {
+ if ( $s->config->piny_ikiwiki =~ /^(1|true)$/ ) {
+ return ( "\n" );
+ } elsif ( $s->config->piny_ikiwiki =~ /^(0|false)$/ ) {
+ return ( "Redirect /" . $s->name . " " . $s->cgit_url "/tree\n" );
+ } else {
+ die ( $s->config->piny_ikiwiki . " is an unhandled value!" );
+ };
+ } elsif ( $s->config->core_sharedrepository =~ /^(0660|true|1|group)$/ ) or ( $s->config->core_sharedrepository =~ /^(0640|false|0)$/ ) {
+ return ( "Redirect /" . $s->name . " " . $s->ikiwiki_url . "\n" );
} else {
- die ( $s->config->core_sharedrepository . "is an unhandled value!" );
+ die ( $s->config->core_sharedrepository . " is an unhandled value!" );
};
};