File Coverage

lib/Rex/Service/VoidLinux.pm
Criterion Covered Total %
statement 11 24 45.8
branch 0 2 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 15 37 40.5


line stmt bran cond sub pod time code
1             #
2             # (c) 2019 Leah Neukirchen
3             # based on Rex::Service::Gentoo
4             # (c) Jan Gehring
5             #
6              
7             package Rex::Service::VoidLinux;
8              
9 1     1   15 use v5.12.5;
  1         3  
10 1     1   6 use warnings;
  1         2  
  1         39  
11              
12             our $VERSION = '1.14.2.2'; # TRIAL VERSION
13              
14 1     1   5 use Rex::Helper::Run;
  1         3  
  1         72  
15              
16 1     1   8 use base qw(Rex::Service::Base);
  1         2  
  1         267  
17              
18             sub new {
19 0     0 0   my $that = shift;
20 0   0       my $proto = ref($that) || $that;
21 0           my $self = $proto->SUPER::new(@_);
22              
23 0           bless( $self, $proto );
24              
25             $self->{commands} = {
26 0           start => 'ln -sf /etc/sv/%s /var/service',
27             restart => 'sv restart %s',
28             stop => 'rm /var/service/%s',
29             reload => 'sv reload %s',
30             status => 'sv status %s | grep -q ^run:',
31             ensure_stop => 'rm /var/service/%s',
32             ensure_start => 'ln -sf /etc/sv/%s /var/service',
33             service_exists => 'test -d /etc/sv/%s',
34             };
35              
36 0           return $self;
37             }
38              
39             sub action {
40 0     0 0   my ( $self, $service, $action ) = @_;
41              
42 0           my $ret_val;
43             eval {
44 0           i_run "sv $action $service >/dev/null", nohup => 1;
45 0           $ret_val = 1;
46 0 0         } or do {
47 0           $ret_val = 0;
48             };
49              
50 0           return $ret_val;
51             }
52              
53             1;