| 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
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 49 | 0 | return 0; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | return 1; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | 1; | |||||||||||||||||||