mirror of
https://github.com/webmin/webmin.git
synced 2026-06-22 12:10:28 +01:00
Fix to simplify and show only systemd services
This commit is contained in:
@@ -337,11 +337,9 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) {
|
||||
print &ui_links_row(\@links);
|
||||
print &ui_columns_start([ "", $text{'systemd_name'},
|
||||
$config{'desc'} ? $text{'systemd_desc'} : (),
|
||||
$text{'systemd_type'},
|
||||
$text{'systemd_status'},
|
||||
$text{'systemd_boot'},
|
||||
$text{'index_ustatus'} ]);
|
||||
my $units_piped = join('|', map { quotemeta } &get_systemd_unit_types());
|
||||
foreach $u (&list_systemd_services()) {
|
||||
if ($u->{'legacy'}) {
|
||||
$l = "edit_action.cgi?0+".&urlize($u->{'name'});
|
||||
@@ -350,13 +348,7 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) {
|
||||
$l = "edit_systemd.cgi?name=".&urlize($u->{'name'});
|
||||
}
|
||||
my $sname = $u->{'name'};
|
||||
my ($type) = $sname =~ /\.([^.]+)$/;
|
||||
if (defined($type) && $type =~ /^(?:$units_piped)$/) {
|
||||
$sname =~ s/\.$type$//;
|
||||
}
|
||||
else {
|
||||
$type = '';
|
||||
}
|
||||
$sname =~ s/\.service$//;
|
||||
my $title = ($u->{'boot'} == -1 ?
|
||||
&html_escape($sname) :
|
||||
&ui_link($l, &html_escape($sname)));
|
||||
@@ -365,7 +357,6 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) {
|
||||
&ui_checkbox("d", $u->{'name'}, undef),
|
||||
$title,
|
||||
$desc // (),
|
||||
$type,
|
||||
$u->{'fullstatus'} || "<i>$text{'index_unknown'}</i>",
|
||||
$u->{'boot'} == 1 ?
|
||||
&ui_text_color("$text{'yes'}", 'success') :
|
||||
|
||||
@@ -2311,16 +2311,15 @@ if (@list_systemd_services_cache && !$noinit) {
|
||||
return @list_systemd_services_cache;
|
||||
}
|
||||
|
||||
my $units_piped = join('|', &get_systemd_unit_types());
|
||||
|
||||
# Get all systemd unit names
|
||||
my $out = &backquote_command("systemctl list-units --full --all -t service --no-legend");
|
||||
my $ex = $?;
|
||||
foreach my $l (split(/\r?\n/, $out)) {
|
||||
$l =~ s/^[^a-z0-9\-\_\.]+//i;
|
||||
my ($unit, $loaded, $active, $sub, $desc) = split(/\s+/, $l, 5);
|
||||
next if ($unit !~ /\.service$/);
|
||||
my $a = $unit;
|
||||
$a =~ s/\.($units_piped)$//;
|
||||
$a =~ s/\.service$//;
|
||||
my $f = &action_filename($a);
|
||||
if ($unit ne "UNIT" && $loaded eq "loaded" && !-r $f) {
|
||||
push(@units, $unit);
|
||||
@@ -2332,29 +2331,26 @@ foreach my $l (split(/\r?\n/, $out)) {
|
||||
# and so don't show up in systemctl list-units
|
||||
my $root = &get_systemd_root(undef, 1);
|
||||
opendir(UNITS, $root);
|
||||
push(@units, grep { !/\.wants$/ && !/^\./ && !-d "$root/$_" } readdir(UNITS));
|
||||
push(@units, grep { /\.service$/ && !-d "$root/$_" } readdir(UNITS));
|
||||
closedir(UNITS);
|
||||
|
||||
# Also add units from list-unit-files that also don't show up
|
||||
$out = &backquote_command("systemctl list-unit-files -t service --no-legend");
|
||||
foreach my $l (split(/\r?\n/, $out)) {
|
||||
if ($l =~ /^(\S+\.($units_piped))\s+disabled/ ||
|
||||
$l =~ /^(\S+)\s+disabled/) {
|
||||
if ($l =~ /^(\S+\.service)\s+disabled/) {
|
||||
push(@units, $1);
|
||||
}
|
||||
}
|
||||
|
||||
# Skip useless units
|
||||
@units = grep { !/^sys-devices-/ &&
|
||||
!/^\-\.mount/ &&
|
||||
!/^\-\.slice/ &&
|
||||
!/^dev-/ &&
|
||||
!/^systemd-/ } @units;
|
||||
@units = &unique(@units);
|
||||
|
||||
# Filter out templates
|
||||
my @templates = grep { /\@$/ || /\@\.($units_piped)$/ } @units;
|
||||
@units = grep { !/\@$/ && !/\@\.($units_piped)$/ } @units;
|
||||
my @templates = grep { /\@$/ || /\@\.service$/ } @units;
|
||||
@units = grep { !/\@$/ && !/\@\.service$/ } @units;
|
||||
|
||||
# Dump state of all of them, 100 at a time
|
||||
my %info;
|
||||
|
||||
Reference in New Issue
Block a user