mirror of
https://github.com/webmin/webmin.git
synced 2026-08-07 16:30:38 +01:00
Merge pull request #1712 from webmin/dev/setup-better-postclean
Add a better way to run conditional command
This commit is contained in:
@@ -333,6 +333,10 @@ if [ "\$inetd" != "1" ]; then
|
||||
/etc/$baseproduct/.post-install >/dev/null 2>&1 </dev/null
|
||||
else
|
||||
/etc/$baseproduct/.reload-init >/dev/null 2>&1 </dev/null
|
||||
if [ -f /etc/$baseproduct/.reload-init-systemd ]; then
|
||||
/etc/$baseproduct/.reload-init-systemd >/dev/null 2>&1 </dev/null
|
||||
rm -f /etc/$baseproduct/.reload-init-systemd
|
||||
fi
|
||||
fi
|
||||
else
|
||||
/etc/$baseproduct/restart >/dev/null 2>&1 </dev/null
|
||||
|
||||
@@ -227,6 +227,10 @@ if [ "\$inetd" != "1" ]; then
|
||||
/etc/webmin/.post-install >/dev/null 2>&1 </dev/null
|
||||
else
|
||||
/etc/webmin/.reload-init >/dev/null 2>&1 </dev/null
|
||||
if [ -f /etc/webmin/.reload-init-systemd ]; then
|
||||
/etc/webmin/.reload-init-systemd >/dev/null 2>&1 </dev/null
|
||||
rm -f /etc/webmin/.reload-init-systemd
|
||||
fi
|
||||
fi
|
||||
if [ "\$?" != "0" ]; then
|
||||
echo "warning: Webmin server cannot be restarted. It is advised to restart it manually\n by running \\"/etc/webmin/restart-by-force-kill\\" when upgrade process is finished"
|
||||
|
||||
24
setup.pl
24
setup.pl
@@ -534,7 +534,7 @@ if (!$ENV{'noperlpath"'} && $os_type ne 'windows') {
|
||||
print ".. done\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
my $systemctlcmd = &has_command('systemctl');
|
||||
print "Creating start and stop scripts ..\n";
|
||||
if ($os_type eq "windows") {
|
||||
open(START, ">>$config_directory/start.bat");
|
||||
@@ -629,6 +629,18 @@ else {
|
||||
print RELOAD "kill -USR1 \`cat \$pidfile\`\n";
|
||||
close(RELOAD);
|
||||
|
||||
# Switch to systemd from init (intermediate)
|
||||
if ($killmodenonepl == 1 && -x $systemctlcmd) {
|
||||
if ($ver < 1.994) {
|
||||
open(SDRELOAD, ">$config_directory/.reload-init-systemd");
|
||||
print SDRELOAD "#!/bin/sh\n";
|
||||
print SDRELOAD "$config_directory/.stop-init\n";
|
||||
print SDRELOAD "$config_directory/start\n";
|
||||
close(SDRELOAD);
|
||||
chmod(0755, "$config_directory/.reload-init-systemd");
|
||||
}
|
||||
}
|
||||
|
||||
# Pre install
|
||||
open(PREINST, ">$config_directory/.pre-install");
|
||||
print PREINST "#!/bin/sh\n";
|
||||
@@ -671,7 +683,6 @@ else {
|
||||
symlink("$config_directory/.reload-init", "$config_directory/reload");
|
||||
|
||||
# For systemd
|
||||
my $systemctlcmd = &has_command('systemctl');
|
||||
if (-x $systemctlcmd) {
|
||||
|
||||
# Clear existing
|
||||
@@ -894,8 +905,17 @@ if (!$ENV{'nostart'}) {
|
||||
if ($upgrading) {
|
||||
$action = 'restart';
|
||||
}
|
||||
my $start_cmd_extra;
|
||||
if ($upgrading && $killmodenonepl == 1) {
|
||||
$start_cmd_extra = "$config_directory/.reload-init-systemd";
|
||||
if (-r $start_cmd_extra) {
|
||||
$start_cmd .= " ; $start_cmd_extra";
|
||||
}
|
||||
}
|
||||
print "Attempting to $action Webmin web server ..\n";
|
||||
$ex = system($start_cmd);
|
||||
unlink($start_cmd_extra)
|
||||
if (-r $start_cmd_extra);
|
||||
if ($ex) {
|
||||
&errorexit("Failed to $action web server!");
|
||||
}
|
||||
|
||||
7
setup.sh
7
setup.sh
@@ -674,12 +674,15 @@ echo "#!/bin/sh" >$config_dir/.reload-init
|
||||
echo "echo Reloading Webmin server in $wadir" >>$config_dir/.reload-init
|
||||
echo "pidfile=\`grep \"^pidfile=\" $config_dir/miniserv.conf | sed -e 's/pidfile=//g'\`" >>$config_dir/.reload-init
|
||||
echo "kill -USR1 \`cat \$pidfile\`" >>$config_dir/.reload-init
|
||||
# Switch to systemd from init (intermediate)
|
||||
if [ "$killmodenonesh" = "1" ] && [ -x "$systemctlcmd" ]; then
|
||||
current_version=`cat "$config_dir/version" 2>/dev/null`
|
||||
ancient_version=`echo $current_version 1.994 | awk '{if ($1 < $2) print 1; else print 0}'`
|
||||
if [ "$ancient_version" = "1" ]; then
|
||||
echo "$config_dir/.stop-init" >>$config_dir/.reload-init
|
||||
echo "$config_dir/start" >>$config_dir/.reload-init
|
||||
echo "#!/bin/sh" >$config_dir/.reload-init-systemd
|
||||
echo "$config_dir/.stop-init" >>$config_dir/.reload-init-systemd
|
||||
echo "$config_dir/start" >>$config_dir/.reload-init-systemd
|
||||
chmod 755 $config_dir/.reload-init-systemd
|
||||
fi
|
||||
fi
|
||||
# Pre install
|
||||
|
||||
Reference in New Issue
Block a user