mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Add support to install multiple versions of Webmin with systemd
This commit is contained in:
@@ -12,7 +12,7 @@ my $kill = &has_command("kill");
|
||||
|
||||
if ($init_mode eq "osx") {
|
||||
# Darwin System
|
||||
&enable_at_boot("webmin", "Webmin administration server",
|
||||
&enable_at_boot("$product", "Webmin administration server",
|
||||
"$config_directory/.start-init >/dev/null 2>&1 </dev/null",
|
||||
"$config_directory/.stop-init");
|
||||
}
|
||||
|
||||
30
setup.pl
30
setup.pl
@@ -9,6 +9,7 @@ use Socket;
|
||||
# Find install directory
|
||||
$ENV{'LANG'} = '';
|
||||
$0 =~ s/\\/\//g;
|
||||
$bootscript = $ENV{'bootscript'} || "webmin";
|
||||
if ($0 =~ /^(.*)\//) {
|
||||
chdir($1);
|
||||
}
|
||||
@@ -387,6 +388,7 @@ else {
|
||||
'logfile' => "$var_dir/miniserv.log",
|
||||
'errorlog' => "$var_dir/miniserv.error",
|
||||
'pidfile' => "$var_dir/miniserv.pid",
|
||||
'bootscript' => "$bootscript",
|
||||
'logtime' => 168,
|
||||
'ppath' => $ppath,
|
||||
'ssl' => $ssl,
|
||||
@@ -540,7 +542,7 @@ if ($os_type eq "windows") {
|
||||
open(START, ">>$config_directory/start.bat");
|
||||
print START "$perl \"$wadir/miniserv.pl\" $config_directory/miniserv.conf\n";
|
||||
close(START);
|
||||
$start_cmd = "sc start ".($ENV{'bootscript'} || "webmin");
|
||||
$start_cmd = "sc start $bootscript";
|
||||
|
||||
open(STOP, ">>$config_directory/stop.bat");
|
||||
print STOP "echo Not implemented\n";
|
||||
@@ -597,12 +599,12 @@ else {
|
||||
print STOP " touch $var_dir/stop-flag\n";
|
||||
print STOP " if [ \"\$1\" = \"--kill\" ]; then\n";
|
||||
print STOP " sleep 1\n";
|
||||
print STOP " ((ps axf | grep \"webmin\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) || kill -9 -- -\$pid || kill -9 \$pid) 2>/dev/null\n";
|
||||
print STOP " ((ps axf | grep \"$wadir\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) || kill -9 -- -\$pid || kill -9 \$pid) 2>/dev/null\n";
|
||||
print STOP " fi\n";
|
||||
print STOP " exit 0\n";
|
||||
print STOP "else\n";
|
||||
print STOP " if [ \"\$1\" = \"--kill\" ]; then\n";
|
||||
print STOP " (ps axf | grep \"webmin\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) 2>/dev/null\n";
|
||||
print STOP " (ps axf | grep \"$wadir\\\/miniserv\\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) 2>/dev/null\n";
|
||||
print STOP " fi\n";
|
||||
print STOP "fi\n";
|
||||
close(STOP);
|
||||
@@ -694,42 +696,42 @@ else {
|
||||
|
||||
# Start systemd
|
||||
open(STARTD, ">$config_directory/start");
|
||||
print STARTD "$systemctlcmd start webmin\n";
|
||||
print STARTD "$systemctlcmd start $bootscript\n";
|
||||
close(STARTD);
|
||||
|
||||
# Stop systemd
|
||||
open(STOPD, ">$config_directory/stop");
|
||||
print STOPD "$systemctlcmd stop webmin\n";
|
||||
print STOPD "$systemctlcmd stop $bootscript\n";
|
||||
close(STOPD);
|
||||
|
||||
# Restart systemd
|
||||
open(RESTARTD, ">$config_directory/restart");
|
||||
print RESTARTD "$systemctlcmd restart webmin\n";
|
||||
print RESTARTD "$systemctlcmd restart $bootscript\n";
|
||||
close(RESTARTD);
|
||||
|
||||
# Force reload systemd
|
||||
open(FRELOADD, ">$config_directory/restart-by-force-kill");
|
||||
print FRELOADD "$systemctlcmd stop webmin\n";
|
||||
print FRELOADD "$systemctlcmd stop $bootscript\n";
|
||||
print FRELOADD "$config_directory/.stop-init --kill >/dev/null 2>&1\n";
|
||||
print FRELOADD "$systemctlcmd start webmin\n";
|
||||
print FRELOADD "$systemctlcmd start $bootscript\n";
|
||||
close(FRELOADD);
|
||||
|
||||
# Reload systemd
|
||||
open(RELOADD, ">$config_directory/reload");
|
||||
print RELOADD "$systemctlcmd reload webmin\n";
|
||||
print RELOADD "$systemctlcmd reload $bootscript\n";
|
||||
close(RELOADD);
|
||||
|
||||
# Pre install
|
||||
open(PREINSTT, ">$config_directory/.pre-install");
|
||||
print PREINSTT "#!/bin/sh\n";
|
||||
#print PREINSTT "$systemctlcmd kill --signal=SIGSTOP --kill-who=main webmin\n";
|
||||
#print PREINSTT "$systemctlcmd kill --signal=SIGSTOP --kill-who=main $bootscript\n";
|
||||
close(PREINSTT);
|
||||
|
||||
# Post install
|
||||
open(POSTINSTT, ">$config_directory/.post-install");
|
||||
print POSTINSTT "#!/bin/sh\n";
|
||||
#print POSTINSTT "$systemctlcmd kill --signal=SIGCONT --kill-who=main webmin\n";
|
||||
print POSTINSTT "$systemctlcmd kill --signal=SIGHUP --kill-who=main webmin\n";
|
||||
#print POSTINSTT "$systemctlcmd kill --signal=SIGCONT --kill-who=main $bootscript\n";
|
||||
print POSTINSTT "$systemctlcmd kill --signal=SIGHUP --kill-who=main $bootscript\n";
|
||||
close(POSTINSTT);
|
||||
|
||||
chmod(0755, "$config_directory/start");
|
||||
@@ -743,7 +745,7 @@ else {
|
||||
# Fix existing systemd webmin.service file to update start and stop commands
|
||||
my $perl = &get_perl_path();
|
||||
chdir("$wadir/init");
|
||||
system("$perl "."e_path("$wadir/init/updateboot.pl")." webmin");
|
||||
system("$perl "."e_path("$wadir/init/updateboot.pl")." $bootscript");
|
||||
}
|
||||
}
|
||||
print ".. done\n";
|
||||
@@ -805,7 +807,7 @@ $gconfig{'product'} ||= "webmin";
|
||||
if ($makeboot) {
|
||||
print "Configuring Webmin to start at boot time ..\n";
|
||||
chdir("$wadir/init");
|
||||
system("$perl "."e_path("$wadir/init/atboot.pl")." ".$ENV{'bootscript'});
|
||||
system("$perl "."e_path("$wadir/init/atboot.pl")." $bootscript");
|
||||
print ".. done\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
30
setup.sh
30
setup.sh
@@ -8,6 +8,11 @@ LANG=
|
||||
export LANG
|
||||
LANGUAGE=
|
||||
export LANGUAGE
|
||||
|
||||
if [ "$bootscript" = "" ]; then
|
||||
bootscript="webmin"
|
||||
fi
|
||||
|
||||
cd `dirname $0`
|
||||
if [ -x /bin/pwd ]; then
|
||||
wadir=`/bin/pwd`
|
||||
@@ -489,6 +494,7 @@ else
|
||||
echo "logfile=$var_dir/miniserv.log" >> $cfile
|
||||
echo "errorlog=$var_dir/miniserv.error" >> $cfile
|
||||
echo "pidfile=$var_dir/miniserv.pid" >> $cfile
|
||||
echo "bootscript=$bootscript" >> $cfile
|
||||
echo "logtime=168" >> $cfile
|
||||
echo "ssl=$ssl" >> $cfile
|
||||
echo "no_ssl2=1" >> $cfile
|
||||
@@ -653,12 +659,12 @@ echo " kill \$pid || exit 1" >>$config_dir/.stop-init
|
||||
echo " touch $var_dir/stop-flag" >>$config_dir/.stop-init
|
||||
echo " if [ \"\$1\" = \"--kill\" ]; then" >>$config_dir/.stop-init
|
||||
echo " sleep 1" >>$config_dir/.stop-init
|
||||
echo " ((ps axf | grep \"webmin\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) || kill -9 -- -\$pid || kill -9 \$pid) 2>/dev/null" >>$config_dir/.stop-init
|
||||
echo " ((ps axf | grep \"$wadir\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) || kill -9 -- -\$pid || kill -9 \$pid) 2>/dev/null" >>$config_dir/.stop-init
|
||||
echo " fi" >>$config_dir/.stop-init
|
||||
echo " exit 0" >>$config_dir/.stop-init
|
||||
echo "else" >>$config_dir/.stop-init
|
||||
echo " if [ \"\$1\" = \"--kill\" ]; then" >>$config_dir/.stop-init
|
||||
echo " (ps axf | grep \"webmin\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) 2>/dev/null" >>$config_dir/.stop-init
|
||||
echo " (ps axf | grep \"$wadir\/miniserv\.pl\" | awk '{print \"kill -9 -- -\" \$1}' | bash) 2>/dev/null" >>$config_dir/.stop-init
|
||||
echo " fi" >>$config_dir/.stop-init
|
||||
echo "fi" >>$config_dir/.stop-init
|
||||
# Restart main
|
||||
@@ -719,31 +725,31 @@ if [ -x "$systemctlcmd" ]; then
|
||||
echo "Creating start and stop scripts (systemd) .."
|
||||
# Start systemd
|
||||
echo "#!/bin/sh" >$config_dir/start
|
||||
echo "$systemctlcmd start webmin" >>$config_dir/start
|
||||
echo "$systemctlcmd start $bootscript" >>$config_dir/start
|
||||
# Stop systemd
|
||||
echo "#!/bin/sh" >$config_dir/stop
|
||||
echo "$systemctlcmd stop webmin" >>$config_dir/stop
|
||||
echo "$systemctlcmd stop $bootscript" >>$config_dir/stop
|
||||
# Restart systemd
|
||||
echo "#!/bin/sh" >$config_dir/restart
|
||||
echo "$systemctlcmd restart webmin" >>$config_dir/restart
|
||||
echo "$systemctlcmd restart $bootscript" >>$config_dir/restart
|
||||
# Force reload systemd
|
||||
echo "#!/bin/sh" >$config_dir/restart-by-force-kill
|
||||
echo "$systemctlcmd stop webmin" >>$config_dir/restart-by-force-kill
|
||||
echo "$systemctlcmd stop $bootscript" >>$config_dir/restart-by-force-kill
|
||||
echo "$config_dir/.stop-init --kill >/dev/null 2>&1" >>$config_dir/restart-by-force-kill
|
||||
echo "$systemctlcmd start webmin" >>$config_dir/restart-by-force-kill
|
||||
echo "$systemctlcmd start $bootscript" >>$config_dir/restart-by-force-kill
|
||||
# Reload systemd
|
||||
echo "#!/bin/sh" >$config_dir/reload
|
||||
echo "$systemctlcmd reload webmin" >>$config_dir/reload
|
||||
echo "$systemctlcmd reload $bootscript" >>$config_dir/reload
|
||||
# Pre-install on systemd
|
||||
echo "#!/bin/sh" >$config_dir/.pre-install
|
||||
# echo "$systemctlcmd kill --signal=SIGSTOP --kill-who=main webmin" >>$config_dir/.pre-install
|
||||
# echo "$systemctlcmd kill --signal=SIGSTOP --kill-who=main $bootscript" >>$config_dir/.pre-install
|
||||
# Post-install on systemd
|
||||
echo "#!/bin/sh" >$config_dir/.post-install
|
||||
# echo "$systemctlcmd kill --signal=SIGCONT --kill-who=main webmin" >>$config_dir/.post-install
|
||||
echo "$systemctlcmd kill --signal=SIGHUP --kill-who=main webmin" >>$config_dir/.post-install
|
||||
# echo "$systemctlcmd kill --signal=SIGCONT --kill-who=main $bootscript" >>$config_dir/.post-install
|
||||
echo "$systemctlcmd kill --signal=SIGHUP --kill-who=main $bootscript" >>$config_dir/.post-install
|
||||
|
||||
# Fix existing systemd webmin.service file to update start and stop commands
|
||||
(cd "$wadir/init" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/init/updateboot.pl" "webmin")
|
||||
(cd "$wadir/init" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/init/updateboot.pl" "$bootscript")
|
||||
|
||||
chmod 755 $config_dir/stop $config_dir/start $config_dir/restart $config_dir/restart-by-force-kill $config_dir/reload $config_dir/.pre-install $config_dir/.post-install
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user