lib/Rex/Service/Ubuntu.pm

filter: Statementstmt 41.6% 10 / 24 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 32.5% 13 / 40 CC 4 SCAR 18.5
CC
4
Cov
32%
status
12.0
new
6.0
BEGIN
1.0
CRAP 6.4
« blib/lib/Rex/Interface/File/OpenSSH.pm ↑ Summary lib/Rex/CMDB.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Service::Ubuntu;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use base qw(Rex::Service::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
15 0 my $that = shift;
16 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
17 0 my $self = $proto->SUPER::new(@_);
18  
19 0 bless( $self, $proto );
20  
21 $self->{commands} = {
22 0 start => '/usr/sbin/service %s start',
23 restart => '/usr/sbin/service %s restart',
24 stop => '/usr/sbin/service %s stop',
25 reload => '/usr/sbin/service %s reload',
26 status => '/usr/sbin/service %s status',
27 ensure_stop => '/usr/sbin/update-rc.d -f %s remove',
28 ensure_start => '/usr/sbin/update-rc.d %s defaults',
29 action => '/usr/sbin/service %s %s',
30 service_exists => '/usr/sbin/service --status-all 2>&1 | grep %s',
31 };
32  
33 0 return $self;
34 }
35  
36 0 ▶sub status {
Subroutine status: not called CC=3 SCAR=24.8
Pod undocumented
37 0 my ( $self, $service, $options ) = @_;
38  
39 0 my $ret = $self->SUPER::status( $service, $options );
40  
41 # bad... really bad ...
42 0 ▶ if ( $ret == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret == 0) 0 0 0
43 0 return 0;
44 }
45  
46 0 my $output = $self->get_output;
47  
48 0 ▶ if ( $output =~ m/NOT running|stop\//ms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output =~ m[NOT running|stop/]msu) 0 0 0
49 0 return 0;
50 }
51  
52 0 return 1;
53 }
54  
55 1 1;
« blib/lib/Rex/Interface/File/OpenSSH.pm ↑ Summary lib/Rex/CMDB.pm »