Merge pull request #2512 from webmin/dev/init-systemd-improvements

Add improvements to systemd section of Init module
This commit is contained in:
Jamie Cameron
2025-07-14 18:23:11 +08:00
committed by GitHub
4 changed files with 35 additions and 11 deletions

View File

@ -422,6 +422,10 @@ details.ui_hidden_table_start > summary::-webkit-details-marker {
color: #a1acc0; color: #a1acc0;
} }
details:not([open]).on-hover:not(:hover) summary::after {
visibility: hidden !important;
}
details.inline { details.inline {
cursor: pointer; cursor: pointer;
padding: 0; padding: 0;

View File

@ -335,11 +335,13 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) {
&select_invert_link("d"), &select_invert_link("d"),
&ui_link("edit_systemd.cgi?new=1", $text{'index_sadd'}) ); &ui_link("edit_systemd.cgi?new=1", $text{'index_sadd'}) );
print &ui_links_row(\@links); print &ui_links_row(\@links);
print &ui_columns_start([ "", $text{'index_uname'}, print &ui_columns_start([ "", $text{'systemd_name'},
$text{'index_udesc'}, $config{'desc'} ? $text{'systemd_desc'} : (),
$text{'index_ucstatus'}, $text{'systemd_type'},
$text{'index_uboot'}, $text{'systemd_status'},
$text{'index_ustatus'}, ]); $text{'systemd_boot'},
$text{'index_ustatus'} ]);
my $units_piped = join('|', map { quotemeta } &get_systemd_unit_types());
foreach $u (&list_systemd_services()) { foreach $u (&list_systemd_services()) {
if ($u->{'legacy'}) { if ($u->{'legacy'}) {
$l = "edit_action.cgi?0+".&urlize($u->{'name'}); $l = "edit_action.cgi?0+".&urlize($u->{'name'});
@ -348,13 +350,22 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) {
$l = "edit_systemd.cgi?name=".&urlize($u->{'name'}); $l = "edit_systemd.cgi?name=".&urlize($u->{'name'});
} }
my $sname = $u->{'name'}; my $sname = $u->{'name'};
$sname =~ s/\.service$//; my ($type) = $sname =~ /\.([^.]+)$/;
if (defined($type) && $type =~ /^(?:$units_piped)$/) {
$sname =~ s/\.$type$//;
}
else {
$type = '';
}
my $title = ($u->{'boot'} == -1 ?
&html_escape($sname) :
&ui_link($l, &html_escape($sname)));
my $desc = $config{'desc'} ? &html_escape($u->{'desc'}) : undef;
print &ui_columns_row([ print &ui_columns_row([
&ui_checkbox("d", $u->{'name'}, undef), &ui_checkbox("d", $u->{'name'}, undef),
$u->{'boot'} == -1 ? $title,
&html_escape($sname) : $desc // (),
&ui_link($l, &html_escape($sname)), $type,
&html_escape($u->{'desc'}),
$u->{'fullstatus'} || "<i>$text{'index_unknown'}</i>", $u->{'fullstatus'} || "<i>$text{'index_unknown'}</i>",
$u->{'boot'} == 1 ? $u->{'boot'} == 1 ?
&ui_text_color("$text{'yes'}", 'success') : &ui_text_color("$text{'yes'}", 'success') :

View File

@ -2181,7 +2181,7 @@ while(@units) {
while(@args < 100 && @units) { while(@args < 100 && @units) {
push(@args, shift(@units)); push(@args, shift(@units));
} }
my $out = &backquote_command("systemctl show --property=Id,Description,UnitFileState,ActiveState,SubState,ExecStart,ExecStop,ExecReload,ExecMainPID,FragmentPath ".join(" ", @args)." 2>/dev/null"); my $out = &backquote_command("systemctl show --property=Id,Description,UnitFileState,ActiveState,SubState,ExecStart,ExecStop,ExecReload,ExecMainPID,FragmentPath,DropInPaths ".join(" ", @args)." 2>/dev/null");
my @lines = split(/\r?\n/, $out); my @lines = split(/\r?\n/, $out);
my $curr; my $curr;
my @units; my @units;
@ -2901,4 +2901,12 @@ my ($name) = @_;
return $name =~ /\./ ? $name : "com.webmin.".$name; return $name =~ /\./ ? $name : "com.webmin.".$name;
} }
# config_pre_load(mod-info, [mod-order])
# Check if some config options are conditional
sub config_pre_load
{
my ($modconf_info, $modconf_order) = @_;
$modconf_info->{'desc'} =~ s/2-[^,]+,// if ($init_mode eq "systemd");
}
1; 1;

View File

@ -227,6 +227,7 @@ systemd_egone=Unit no longer exists!
systemd_elegacy=Not a systemd unit! systemd_elegacy=Not a systemd unit!
systemd_header=Systemd unit details systemd_header=Systemd unit details
systemd_name=Unit name systemd_name=Unit name
systemd_type=Unit type
systemd_file=Configuration file systemd_file=Configuration file
systemd_desc=Unit description systemd_desc=Unit description
systemd_start=Commands to run on startup systemd_start=Commands to run on startup