From 8a684d8c4158b71dae71920540bb80024ab26fd4 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 20 Oct 2018 10:33:26 -0700 Subject: [PATCH] Detect and show unknown status systemd actions https://www.virtualmin.com/node/59115 --- init/edit_systemd.cgi | 8 +++++--- init/index.cgi | 6 ++++-- init/init-lib.pl | 4 ++-- init/lang/en | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/init/edit_systemd.cgi b/init/edit_systemd.cgi index 39fd130cd..87001729c 100755 --- a/init/edit_systemd.cgi +++ b/init/edit_systemd.cgi @@ -59,11 +59,13 @@ else { &ui_yesno_radio("boot", $u->{'boot'})); } print &ui_table_row($text{'systemd_status'}, - $u->{'status'} && $u->{'pid'} ? + $u->{'status'} == 1 && $u->{'pid'} ? &text('systemd_status1', $u->{'pid'}) : - $u->{'status'} ? + $u->{'status'} == 1 ? $text{'systemd_status2'} : - $text{'systemd_status0'}); + $u->{'status'} == 0 ? + $text{'systemd_status0'} : + $text{'systemd_status3'}); } print &ui_table_end(); diff --git a/init/index.cgi b/init/index.cgi index 5d1656b4c..23e9cc342 100755 --- a/init/index.cgi +++ b/init/index.cgi @@ -361,8 +361,10 @@ elsif ($init_mode eq "systemd" && $access{'bootup'}) { $u->{'boot'} == 1 ? $text{'yes'} : $u->{'boot'} == 2 ? $text{'index_always'} : "$text{'no'}", - $u->{'status'} ? $text{'yes'} : - "$text{'no'}", + $u->{'status'} == 1 ? $text{'yes'} : + $u->{'status'} == 0 ? + "$text{'no'}" : + "$text{'index_unknown'}", ]); } print &ui_columns_end(); diff --git a/init/init-lib.pl b/init/init-lib.pl index e2c3b834f..384c8c86f 100755 --- a/init/init-lib.pl +++ b/init/init-lib.pl @@ -2088,7 +2088,7 @@ foreach my $name (keys %info) { 'legacy' => 0, 'boot' => $i->{'UnitFileState'} eq 'enabled' ? 1 : $i->{'UnitFileState'} eq 'static' ? 2 : 0, - 'status' => $i->{'ActiveState'} eq 'active', + 'status' => $i->{'ActiveState'} eq 'active' ? 1 : 0, 'start' => $i->{'ExecStart'}, 'stop' => $i->{'ExecStop'}, 'reload' => $i->{'ExecReload'}, @@ -2113,7 +2113,7 @@ foreach my $a (&list_actions()) { my $hasarg = &get_action_args($f); if ($hasarg->{'status'}) { my $r = &action_running($f); - $s->{'status'} = $r == 1 ? 1 : 0; + $s->{'status'} = $r; } push(@rv, $s); } diff --git a/init/lang/en b/init/lang/en index b9d4ae6b0..7fa60f363 100644 --- a/init/lang/en +++ b/init/lang/en @@ -232,6 +232,7 @@ systemd_status=Current status systemd_status0=Not running systemd_status1=Running with PID $1 systemd_status2=Running +systemd_status3=Unknown! systemd_err=Failed to save systemd service systemd_ename=Missing or invalid-lookup systemd service name systemd_eclash=A service with the same name already exists