Protect Webmin from being deleted or stopped, and restart properly

This commit is contained in:
iliajie
2022-10-19 14:25:43 +03:00
parent 18a84c643e
commit 60349eb62e
3 changed files with 21 additions and 4 deletions

View File

@@ -80,7 +80,8 @@ else {
[ 'start', $text{'edit_startnow'} ],
[ 'restart', $text{'edit_restartnow'} ],
[ 'stop', $text{'edit_stopnow'} ],
[ 'delete', $text{'delete'} ] ]);
$in{'name'} eq 'webmin.service' ?
undef : [ 'delete', $text{'delete'} ] ]);
}
&ui_print_footer("", $text{'index_return'});

View File

@@ -162,6 +162,7 @@ edit_hostconfig_title=Edit Hostconfig
mass_enone=No actions selected
mass_enone2=No services selected
mass_enoallow=cannot stop <tt>$1</tt>
mass_start=Starting Actions
mass_restart=Restarting Actions
mass_stop=Stopping Actions
@@ -171,6 +172,7 @@ mass_disable=Disabling action $1 at boot time.
mass_starting=Starting action $1 ..
mass_stopping=Stopping action $1 ..
mass_failed=.. failed
mass_skipped=.. skipped
mass_ok=.. done
mass_ustart=Starting Services
mass_urestart=Restarting Services

View File

@@ -21,16 +21,30 @@ if ($stop || $restart) {
$access{'bootup'} || &error($text{'ss_ecannot'});
$SIG{'TERM'} = 'ignore'; # Restarting webmin may kill this script
foreach $s (@sel) {
my ($ok, $out);
my $is_webmin = $s eq 'webmin.service';
if ($stop) {
print &text('mass_ustopping', "<tt>$s</tt>"),"<br>\n";
($ok, $out) = &stop_action($s);
($ok, $out) = &stop_action($s)
if (!$is_webmin);
}
elsif ($restart) {
print &text('mass_urestarting', "<tt>$s</tt>"),"<br>\n";
($ok, $out) = &restart_action($s);
if (!$is_webmin) {
($ok, $out) = &restart_action($s);
}
else {
&restart_miniserv();
}
}
print "<pre>$out</pre>" if ($out);
if (!$ok) {
if ($is_webmin) {
print "$text{'mass_skipped'} : ". &text('mass_enoallow', $s),"<p></p>\n"
if ($stop);
print $text{'mass_ok'},"<p></p>\n"
if ($restart);
}
elsif (!$ok) {
print $text{'mass_failed'},"<p></p>\n";
}
else {