From 8f8199a4bf2fba1fbda0856fcab5c8125e29010d Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 13 Jun 2026 00:14:08 +0200 Subject: [PATCH] Fix to simplify and show only systemd services --- init/index.cgi | 11 +---------- init/init-lib.pl | 16 ++++++---------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/init/index.cgi b/init/index.cgi index c87868ae9..b5bf9863e 100755 --- a/init/index.cgi +++ b/init/index.cgi @@ -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'} || "$text{'index_unknown'}", $u->{'boot'} == 1 ? &ui_text_color("$text{'yes'}", 'success') : diff --git a/init/init-lib.pl b/init/init-lib.pl index e3c25b8fa..b49f28d58 100644 --- a/init/init-lib.pl +++ b/init/init-lib.pl @@ -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;