mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Fix to ensure systemd custom units are created in the correct directory
This commit is contained in:
@@ -2147,7 +2147,7 @@ foreach my $l (split(/\r?\n/, $out)) {
|
|||||||
|
|
||||||
# Also find unit files for units that may be disabled at boot and not running,
|
# Also find unit files for units that may be disabled at boot and not running,
|
||||||
# and so don't show up in systemctl list-units
|
# and so don't show up in systemctl list-units
|
||||||
my $root = &get_systemd_root();
|
my $root = &get_systemd_root(undef, 1);
|
||||||
opendir(UNITS, $root);
|
opendir(UNITS, $root);
|
||||||
push(@units, grep { !/\.wants$/ && !/^\./ && !-d "$root/$_" } readdir(UNITS));
|
push(@units, grep { !/\.wants$/ && !/^\./ && !-d "$root/$_" } readdir(UNITS));
|
||||||
closedir(UNITS);
|
closedir(UNITS);
|
||||||
@@ -2452,14 +2452,14 @@ foreach my $s (&list_systemd_services(1)) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 get_systemd_root([name])
|
=head2 get_systemd_root([name], [packaged])
|
||||||
|
|
||||||
Returns the base directory for systemd unit config files
|
Returns the base directory for systemd unit config files
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
sub get_systemd_root
|
sub get_systemd_root
|
||||||
{
|
{
|
||||||
my ($name) = @_;
|
my ($name, $packaged) = @_;
|
||||||
# Default systemd paths
|
# Default systemd paths
|
||||||
my $systemd_local_conf = "/etc/systemd/system";
|
my $systemd_local_conf = "/etc/systemd/system";
|
||||||
my $systemd_unit_dir1 = "/usr/lib/systemd/system";
|
my $systemd_unit_dir1 = "/usr/lib/systemd/system";
|
||||||
@@ -2485,6 +2485,9 @@ if ($name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# Always use /etc/systemd/system for locally created units
|
||||||
|
return $systemd_local_conf if (!$packaged && -d $systemd_local_conf);
|
||||||
|
|
||||||
# Debian prefers /lib/systemd/system
|
# Debian prefers /lib/systemd/system
|
||||||
if ($gconfig{'os_type'} eq 'debian-linux' &&
|
if ($gconfig{'os_type'} eq 'debian-linux' &&
|
||||||
-d $systemd_unit_dir2) {
|
-d $systemd_unit_dir2) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if ($product) {
|
|||||||
quotemeta($product).".service 2>&1");
|
quotemeta($product).".service 2>&1");
|
||||||
$status = &trim($status) if ($status);
|
$status = &trim($status) if ($status);
|
||||||
# Delete all possible service files
|
# Delete all possible service files
|
||||||
my $systemd_root = &get_systemd_root();
|
my $systemd_root = &get_systemd_root(undef, 1);
|
||||||
foreach my $p (
|
foreach my $p (
|
||||||
"/etc/systemd/system",
|
"/etc/systemd/system",
|
||||||
"/usr/lib/systemd/system",
|
"/usr/lib/systemd/system",
|
||||||
|
|||||||
Reference in New Issue
Block a user