diff --git a/apache/apache-lib.pl b/apache/apache-lib.pl index 0e60e508e..545008af5 100755 --- a/apache/apache-lib.pl +++ b/apache/apache-lib.pl @@ -17,6 +17,8 @@ else { map { $access_types{$_}++ } @access_types; $site_file = ($config{'webmin_apache'} || $module_config_directory)."/site"; $httpd_info_cache = $module_config_directory."/httpd-info"; +$last_config_change_flag = $module_var_directory."/config-flag"; +$last_restart_time_flag = $module_var_directory."/restart-flag"; # Check if a list of supported modules needs to be built. This is done # if the Apache binary changes, when Webmin is upgraded, or once every five @@ -606,6 +608,7 @@ for($i=0; $i<@old || $i<@{$_[1]}; $i++) { $change = $old[$i]; } } +&update_last_config_change(); return &unique(@files); } @@ -686,6 +689,7 @@ elsif (!$olddir && $newdir) { $newdir->{'file'}); } } +&update_last_config_change(); } # recursive_set_lines_files(&directives, first-line, file) @@ -1167,12 +1171,18 @@ print "
\n"; # Returns HTML for a link to put in the top-right corner of every page sub restart_button { -local $rv; -$args = "redir=".&urlize(&this_url()); +local $args = "redir=".&urlize(&this_url()); local @rv; if (&is_apache_running()) { if ($access{'apply'}) { - push(@rv, &ui_link("restart.cgi?$args", $text{'apache_apply'}) ); + my $n = &needs_config_restart(); + if ($n) { + push(@rv, &ui_link("restart.cgi?$args&newconfig=1", + "$text{'apache_apply'}") ); + } + else { + push(@rv, &ui_link("restart.cgi?$args", $text{'apache_apply'}) ); + } } if ($access{'stop'}) { push(@rv, &ui_link("stop.cgi?$args", $text{'apache_stop'}) ); @@ -1586,6 +1596,7 @@ else { &kill_logged('HUP', $1) || return &text('restart_esig', $1); &wait_for_graceful(); } +&restart_last_restart_time(); return undef; } @@ -2040,5 +2051,33 @@ local $d = &virtual_server::get_domain_by("dom", $n); return $d; } +# update_last_config_change() +# Updates the flag file indicating when the config was changed +sub update_last_config_change +{ +&open_tempfile(FLAG, ">$last_config_change_flag", 0, 1); +&close_tempfile(FLAG); +} + +# restart_last_restart_time() +# Updates the flag file indicating when the config was changed +sub restart_last_restart_time +{ +&open_tempfile(FLAG, ">$last_restart_time_flag", 0, 1); +&close_tempfile(FLAG); +} + +# needs_config_restart() +# Returns 1 if a restart is needed for sure after a config change +sub needs_config_restart +{ +my @cst = stat($last_config_change_flag); +my @rst = stat($last_restart_time_flag); +if (@cst && @rst && $cst[9] > $rst[9]) { + return 1; + } +return 0; +} + 1; diff --git a/apache/change_dir.cgi b/apache/change_dir.cgi index 23226a533..c4a51e765 100755 --- a/apache/change_dir.cgi +++ b/apache/change_dir.cgi @@ -41,6 +41,7 @@ else { } &flush_file_lines(); &unlock_file($d->{'file'}); +&update_last_config_change(); &after_changing(); &webmin_log("dir", $in{'delete'} ? 'delete' : 'save', diff --git a/apache/change_files.cgi b/apache/change_files.cgi index 2080061a2..559eea53f 100755 --- a/apache/change_files.cgi +++ b/apache/change_files.cgi @@ -36,6 +36,7 @@ else { } &flush_file_lines(); &unlock_file($d->{'file'}); +&update_last_config_change(); &after_changing(); &webmin_log("files", $in{'delete'} ? 'delete' : 'save', diff --git a/apache/create_dir.cgi b/apache/create_dir.cgi index 43c517d2a..aae4167a2 100755 --- a/apache/create_dir.cgi +++ b/apache/create_dir.cgi @@ -37,6 +37,7 @@ else { # Add to file &save_directive_struct(undef, $dir, $vconf, $conf); &flush_file_lines(); +&update_last_config_change(); &unlock_file($vconf->[0]->{'file'}); &after_changing(); diff --git a/apache/create_files.cgi b/apache/create_files.cgi index 42c113730..4a9ac0ce7 100755 --- a/apache/create_files.cgi +++ b/apache/create_files.cgi @@ -31,6 +31,7 @@ else { # Add to file &save_directive_struct(undef, $dir, $hconf, $hconf); &flush_file_lines(); +&update_last_config_change(); &unlock_file($in{'file'}); &after_changing(); diff --git a/apache/create_virt.cgi b/apache/create_virt.cgi index e9621f3b4..56c29c961 100755 --- a/apache/create_virt.cgi +++ b/apache/create_virt.cgi @@ -240,6 +240,7 @@ if ($in{'adddir'} && $in{'root'}) { &save_directive_struct(undef, $virt, $conf, $conf); &flush_file_lines(); &unlock_file($f); +&update_last_config_change(); &unlock_apache_files(); # Create a symlink from another dir, if requested (as in Debian) diff --git a/apache/delete_vservs.cgi b/apache/delete_vservs.cgi index 28fdf9bb4..c5901f6d5 100755 --- a/apache/delete_vservs.cgi +++ b/apache/delete_vservs.cgi @@ -26,6 +26,7 @@ foreach $vconf (@virts) { } &flush_file_lines(); &unlock_all_files(); +&update_last_config_change(); &after_changing(); &webmin_log("virts", "delete", scalar(@virts)); &redirect(""); diff --git a/apache/manual_save.cgi b/apache/manual_save.cgi index 42a73dc3d..f23a7d99f 100755 --- a/apache/manual_save.cgi +++ b/apache/manual_save.cgi @@ -75,6 +75,7 @@ if ($config{'test_manual'}) { } unlink($temp); &unlock_file($file); +&update_last_config_change(); &webmin_log($logtype, "manual", $logname, \%in); foreach $h ('virt', 'idx', 'file') { diff --git a/apache/save_vserv.cgi b/apache/save_vserv.cgi index 0355d6da9..7e5a98d66 100755 --- a/apache/save_vserv.cgi +++ b/apache/save_vserv.cgi @@ -18,6 +18,7 @@ if ($in{'delete'}) { &delete_file_if_empty($vconf->{'file'}); &flush_file_lines(); &unlock_file($vconf->{'file'}); + &update_last_config_change(); &after_changing(); diff --git a/webmin/postinstall.pl b/webmin/postinstall.pl index 7653b1d1c..495b9ab20 100755 --- a/webmin/postinstall.pl +++ b/webmin/postinstall.pl @@ -48,6 +48,13 @@ if (!-r $first_install_file || $miniserv{'login_script'} eq $record_login_cmd) { &put_miniserv_config(\%miniserv); &unlock_file("$config_directory/miniserv.conf"); +# Create a link from /usr/sbin/webmin to bin/webmin under the root dir +my $bindir = "/usr/sbin"; +my $lnk = $bindir."/webmin"; +if (-d $bindir && !-e $lnk) { + &symlink_file($lnk, $root_directory."/bin/webmin"); + } + # Record the version of Webmin at first install if (!-r $first_install_file) { my %first; diff --git a/webmin/uninstall.pl b/webmin/uninstall.pl index 8ef67a5dd..83619b0cb 100755 --- a/webmin/uninstall.pl +++ b/webmin/uninstall.pl @@ -5,8 +5,9 @@ require 'webmin-lib.pl'; sub module_uninstall { +# Remove the update cron job, if enabled if ($config{'update'}) { - &foreign_require("cron", "cron-lib.pl"); + &foreign_require("cron"); $cron_cmd = "$module_config_directory/update.pl"; foreach $j (&cron::list_cron_jobs()) { if ($j->{'user'} eq 'root' && @@ -15,6 +16,13 @@ if ($config{'update'}) { } } } + +# Remove the link from /usr/sbin/webmin +my $bindir = "/usr/sbin"; +my $lnk = $bindir."/webmin"; +if (-l $lnk) { + unlink($lnk); + } } 1;