From d3d06161d535d965867902f84b6e2ac558ce10c6 Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Wed, 11 May 2011 20:07:50 -0700 Subject: Making Piny::Repo->rebuild_wikilist function --- libpiny/lib/Piny/Repo.pm | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'libpiny') 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 ; - 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", $_ ); -- cgit v1.2.3