diff --git a/setup.pl b/setup.pl index 4f013cbc8..48a3ec113 100755 --- a/setup.pl +++ b/setup.pl @@ -632,7 +632,13 @@ else { # Stop systemd open(STOPD, ">$config_directory/stop"); - print STOPD "$systemctlcmd stop webmin\n"; + print STOPD "if [ \"\$1\" = \"--grace\" ]; then\n"; + print STOPD " $systemctlcmd kill -s SIGHUP webmin\n"; + print STOPD "elif [ \"\$1\" = \"--force\" ]; then\n"; + print STOPD " $systemctlcmd kill -s SIGKILL webmin\n"; + print STOPD "else\n"; + print STOPD " $systemctlcmd stop webmin\n"; + print STOPD "fi\n"; close(STOPD); # Restart systemd diff --git a/setup.sh b/setup.sh index db7387ebb..822c82888 100755 --- a/setup.sh +++ b/setup.sh @@ -688,7 +688,13 @@ if [ -x "$systemctlcmd" ]; then echo "$systemctlcmd start webmin" >>$config_dir/start # Stop systemd echo "#!/bin/sh" >>$config_dir/stop - echo "$systemctlcmd stop webmin" >>$config_dir/stop + echo "if [ \"\$1\" = \"--grace\" ]; then" >>$config_dir/stop + echo " $systemctlcmd kill -s SIGHUP webmin" >>$config_dir/stop + echo "elif [ \"\$1\" = \"--force\" ]; then" >>$config_dir/stop + echo " $systemctlcmd kill -s SIGKILL webmin" >>$config_dir/stop + echo "else" >>$config_dir/stop + echo " $systemctlcmd stop webmin" >>$config_dir/stop + echo "fi" >>$config_dir/stop # Restart systemd echo "#!/bin/sh" >>$config_dir/restart echo "$systemctlcmd restart webmin" >>$config_dir/restart diff --git a/webmin-systemd b/webmin-systemd index fad208d31..dc064c113 100644 --- a/webmin-systemd +++ b/webmin-systemd @@ -7,7 +7,10 @@ ExecStart=/etc/webmin/.start-init ExecStop=/etc/webmin/.stop-init PIDFile=/var/webmin/miniserv.pid Type=forking -KillMode=none +Restart=always +RestartSec=3s +StartLimitBurst=3 +StartLimitIntervalSec=3 [Install] WantedBy=multi-user.target diff --git a/webmin/change_bind.cgi b/webmin/change_bind.cgi index 97cfe86c5..e97d2813e 100755 --- a/webmin/change_bind.cgi +++ b/webmin/change_bind.cgi @@ -135,7 +135,7 @@ else { # Attempt to re-start miniserv $SIG{'TERM'} = 'ignore'; -&system_logged("$config_directory/stop >/dev/null 2>&1 /dev/null 2>&1 $temp 2>&1 \n"; print "\n"; &ui_print_footer("", $text{'index_return'}); + # In case of systemd kill service to be auto-restarted by systemd + if (&has_command('systemctl')) { + &system_logged("$config_directory/stop --force >/dev/null 2>&1 /dev/null 2>&1