summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2011-05-11 20:07:50 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2011-05-11 20:07:50 -0700
commitd3d06161d535d965867902f84b6e2ac558ce10c6 (patch)
tree976d4ca8aba30d4a86b004fa18c34ef07496f78f
parent61c4748cbe812c1bd4a1772354326792b3d9aa33 (diff)
downloadpiny-code-d3d06161d535d965867902f84b6e2ac558ce10c6.tar.gz
piny-code-d3d06161d535d965867902f84b6e2ac558ce10c6.zip
Making Piny::Repo->rebuild_wikilist function
-rw-r--r--libpiny/lib/Piny/Repo.pm46
1 files changed, 19 insertions, 27 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index b6fea4d..f4dca6e 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -283,6 +283,21 @@ sub rebuild_ikiwiki {
print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $s->name . ".setup\n";
close( WIKILIST ) or die "Could not close wikilist.d file: $!";
+ $s->rebuild_wikilist;
+
+ system( "/usr/bin/sudo", "-u", $ikiuser->name, "/usr/bin/ikiwiki", "--setup", "/etc/ikiwiki/piny/" . $s->name . ".setup" ) and die "Could not do initial compile of ikiwiki!";
+
+ open( APACHE, ">", "/etc/apache2/piny-available/" . $s->name ) or die "Could not open new apache config: $!";
+ print APACHE $s->apache_config;
+ close( APACHE ) or die "Could not close new apache config: $!";
+
+ unlink( "/etc/apache2/piny-enabled/" . $s->name );
+ symlink( "/etc/apache2/piny-available/" . $s->name, "/etc/apache2/piny-enabled/" . $s->name ) or die "Could not symlink apache config: $!";
+
+ system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
+};
+
+sub rebuild_wikilist {
my $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
$temp->unlink_on_destroy( 0 );
@@ -299,17 +314,6 @@ sub rebuild_ikiwiki {
chmod( 00644, $temp->filename ) or die "Could not fix mode of new wikilist: $!";
rename( $temp->filename, "/etc/ikiwiki/wikilist" ) or die "Could not rename over old wikilist: $!";
-
- system( "/usr/bin/sudo", "-u", $ikiuser->name, "/usr/bin/ikiwiki", "--setup", "/etc/ikiwiki/piny/" . $s->name . ".setup" ) and die "Could not do initial compile of ikiwiki!";
-
- open( APACHE, ">", "/etc/apache2/piny-available/" . $s->name ) or die "Could not open new apache config: $!";
- print APACHE $s->apache_config;
- close( APACHE ) or die "Could not close new apache config: $!";
-
- unlink( "/etc/apache2/piny-enabled/" . $s->name );
- symlink( "/etc/apache2/piny-available/" . $s->name, "/etc/apache2/piny-enabled/" . $s->name ) or die "Could not symlink apache config: $!";
-
- system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
};
sub destroy {
@@ -330,7 +334,7 @@ sub destroy_ikiwiki {
my $user = Piny::Environment->instance->user;
- foreach( "/etc/apache2/piny-enabled/" . $s->name, "/etc/apache2/piny-available/" . $s->name, "/etc/ikiwiki/wikilist.d/" . $s->name ) {
+ foreach( "/etc/apache2/piny-enabled/" . $s->name, "/etc/apache2/piny-available/" . $s->name, ) {
if ( -e $_ ) {
unlink( $_ );
};
@@ -338,23 +342,11 @@ sub destroy_ikiwiki {
system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
- my $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
- $temp->unlink_on_destroy( 0 );
-
- my $dh = IO::Dir->new( "/etc/ikiwiki/wikilist.d" ) or die "Could not open wikilist.d directory: $!";
- while ( defined ( my $entry = $dh->read ) ) {
- next if ( $entry =~ /^\./ );
- open( FILE, "<", "/etc/ikiwiki/wikilist.d/" . $entry ) or die "Could not open wikilist.d entry $entry: $!";
- print $temp <FILE>;
- close( FILE ) or die "Could not close wikilist.d entry $entry: $!";
+ if ( -e "/etc/ikiwiki/wikilist.d/" . $s->name ) {
+ unlink( $_ );
+ $s->rebuild_wikilist;
};
- $temp->close or die "Could not close new wikilist: $!";
-
- chmod( 00644, $temp->filename ) or die "Could not fix mode of new wikilist: $!";
-
- rename( $temp->filename, "/etc/ikiwiki/wikilist" ) or die "Could not rename over old wikilist: $!";
-
foreach( $s->secure_path, $s->ikiwiki_destdir, $s->ikiwiki_srcdir, "/etc/ikiwiki/piny/" . $s->name . ".setup" ) {
if ( -e $_ ) {
system( "rm", "-rf", $_ );