mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
More work on systemd support
This commit is contained in:
@@ -117,12 +117,15 @@ elsif ($init_mode eq "win32") {
|
||||
$perl_path = &get_perl_path();
|
||||
&enable_at_boot($product, $ucproduct, $perl_path." "."e_path("$root_directory/miniserv.pl")." "."e_path("$config_directory/miniserv.conf"));
|
||||
}
|
||||
elsif ($init_mode eq "rc" || $init_mode eq "upstart") {
|
||||
elsif ($init_mode eq "rc" || $init_mode eq "upstart" ||
|
||||
$init_mode eq "systemd") {
|
||||
# Create RC or upstart script
|
||||
&enable_at_boot($product, $ucproduct, "$config_directory/start",
|
||||
"$config_directory/stop",
|
||||
undef,
|
||||
{ 'fork' => 1 });
|
||||
$name = $init_mode eq "systemd" ? $product.".service" : $product;
|
||||
&enable_at_boot($name, $ucproduct, "$config_directory/start",
|
||||
"$config_directory/stop",
|
||||
undef,
|
||||
{ 'fork' => 1,
|
||||
'pidfile' => $var_directory."/miniserv.pid" });
|
||||
}
|
||||
|
||||
$config{'atboot_product'} = $product;
|
||||
|
||||
@@ -62,3 +62,7 @@ elsif ($init_mode eq "upstart") {
|
||||
# Delete upstart service
|
||||
&delete_upstart_service($product);
|
||||
}
|
||||
elsif ($init_mode eq "systemd") {
|
||||
# Delete systemd service
|
||||
&delete_systemd_service($product.".service");
|
||||
}
|
||||
|
||||
@@ -653,14 +653,13 @@ if ($init_mode eq "systemd" && (!-r "$config{'init_dir'}/$_[0]" ||
|
||||
# Create systemd unit if missing, as long as this isn't an old-style
|
||||
# init script
|
||||
my $cfile = &get_systemd_root()."/".$_[0];
|
||||
if (-r $cfile) {
|
||||
&system_logged("systemctl enable ".
|
||||
quotemeta($_[0])." >/dev/null 2>&1");
|
||||
}
|
||||
else {
|
||||
if (!-r $cfile) {
|
||||
# Need to create config
|
||||
&create_systemd_service($_[0], $_[1], $_[2], $_[3]);
|
||||
&create_systemd_service($_[0], $_[1], $_[2], $_[3], undef,
|
||||
$_[5]->{'fork'}, $_[5]->{'pidfile'});
|
||||
}
|
||||
&system_logged("systemctl enable ".
|
||||
quotemeta($_[0])." >/dev/null 2>&1");
|
||||
return;
|
||||
}
|
||||
if ($init_mode eq "init" || $init_mode eq "local" || $init_mode eq "upstart" ||
|
||||
@@ -1900,14 +1899,15 @@ my $out = &backquote_logged(
|
||||
return (!$?, $out);
|
||||
}
|
||||
|
||||
=head2 create_systemd_service(name, description, start-script, stop-script, restart-script)
|
||||
=head2 create_systemd_service(name, description, start-script, stop-script,
|
||||
restart-script, [forks], [pidfile])
|
||||
|
||||
Create a new systemd service with the given details.
|
||||
|
||||
=cut
|
||||
sub create_systemd_service
|
||||
{
|
||||
my ($name, $desc, $start, $stop, $restart) = @_;
|
||||
my ($name, $desc, $start, $stop, $restart, $forks, $pidfile) = @_;
|
||||
$start =~ s/\r?\n/ ; /g;
|
||||
$stop =~ s/\r?\n/ ; /g;
|
||||
$restart =~ s/\r?\n/ ; /g;
|
||||
@@ -1920,6 +1920,8 @@ my $cfile = &get_systemd_root()."/".$name;
|
||||
&print_tempfile(CFILE, "ExecStart=$start\n");
|
||||
&print_tempfile(CFILE, "ExecStop=$stop\n") if ($stop);
|
||||
&print_tempfile(CFILE, "ExecReload=$restart\n") if ($restart);
|
||||
&print_tempfile(CFILE, "Type=forking\n") if ($forks);
|
||||
&print_tempfile(CFILE, "PIDFile=$pidfile\n") if ($pidfile);
|
||||
&print_tempfile(CFILE, "\n");
|
||||
&print_tempfile(CFILE, "[Install]\n");
|
||||
&print_tempfile(CFILE, "WantedBy=multi-user.target\n");
|
||||
|
||||
Reference in New Issue
Block a user