| 1 | # | ||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Service::NetBSD; | ||||||||||||||||||||
| 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 Rex::Commands::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Logger; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | ▶ | use base qw(Rex::Service::Base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | my $that = shift; | |||||||||||||||||||
| 19 | 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
| |||||||||||||||||||||
| 20 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | bless( $self, $proto ); | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | $self->{commands} = { | ||||||||||||||||||||
| 25 | 0 | start => '/etc/rc.d/%s onestart', | |||||||||||||||||||
| 26 | restart => '/etc/rc.d/%s onerestart', | ||||||||||||||||||||
| 27 | stop => '/etc/rc.d/%s onestop', | ||||||||||||||||||||
| 28 | reload => '/etc/rc.d/%s onereload', | ||||||||||||||||||||
| 29 | status => '/etc/rc.d/%s onestatus', | ||||||||||||||||||||
| 30 | action => '/etc/rc.d/%s %s', | ||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | return $self; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub ensure { | ||||||||||||||||||
|
Subroutine
ensure: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 37 | 0 | my ( $self, $service, $options ) = @_; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | my $what = $options->{ensure}; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | if ( $what =~ /^stop/ ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 42 | 0 | $self->stop( $service, $options ); | |||||||||||||||||||
| 43 | 0 | file "/etc/rc.conf.d/${service}", ensure => "absent"; | |||||||||||||||||||
| 44 | 0 | delete_lines_matching "/etc/rc.conf", | |||||||||||||||||||
| 45 | matching => qr/^\s*${service}="?((?i)YES)"?/; | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | ▶ | elsif ( $what =~ /^start/ || $what =~ m/^run/ ) { | |||||||||||||||||||
|
Condition0%0/3
$what =~ /^start/u or $what =~ /^run/u
MC/DC0%0/2
$what =~ /^start/u or $what =~ /^run/u
$what =~ /^start/u
$what =~ /^run/u
Truth table0%0/3
A or B
A= $what =~ /^start/uB= $what =~ /^run/u
| |||||||||||||||||||||
| 48 | 0 | $self->start( $service, $options ); | |||||||||||||||||||
| 49 | 0 | file "/etc/rc.conf.d/${service}", ensure => "absent"; | |||||||||||||||||||
| 50 | 0 | append_or_amend_line "/etc/rc.conf", | |||||||||||||||||||
| 51 | line => "${service}=YES", | ||||||||||||||||||||
| 52 | regexp => qr/^\s*${service}="?((?i)YES|NO)"?/; | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | return 1; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||