]> git.proxmox.com Git - pve-manager.git/commitdiff
pve7to8: allow to surpress stderr if checking systemd unit state
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 31 May 2023 09:22:58 +0000 (11:22 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 31 May 2023 09:26:08 +0000 (11:26 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/CLI/pve7to8.pm

index 97a8983d551a962e5e740be7e08c34a4fbf8e750..539ac90df8c7c6c91963aeb13f9f83cf653485b9 100644 (file)
@@ -92,17 +92,21 @@ sub print_header {
 }
 
 my $get_systemd_unit_state = sub {
-    my ($unit) = @_;
+    my ($unit, $surpress_stderr) = @_;
 
     my $state;
     my $filter_output = sub {
        $state = shift;
        chomp $state;
     };
+
+    my %extra = (outfunc => $filter_output, noerr => 1);
+    $extra{errfunc} = sub {  } if $surpress_stderr;
+
     eval {
-       run_command(['systemctl', 'is-enabled', "$unit"], outfunc => $filter_output, noerr => 1);
+       run_command(['systemctl', 'is-enabled', "$unit"], %extra);
        return if !defined($state);
-       run_command(['systemctl', 'is-active', "$unit"], outfunc => $filter_output, noerr => 1);
+       run_command(['systemctl', 'is-active', "$unit"], %extra);
     };
 
     return $state // 'unknown';