File Coverage

lib/Rex/Service/SunOS.pm
Criterion Covered Total %
statement 17 34 50.0
branch 0 4 0.0
condition 0 6 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 23 54 42.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Service::SunOS;
6              
7 1     1   14 use v5.12.5;
  1         3  
8 1     1   5 use warnings;
  1         2  
  1         46  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   16 use Rex::Helper::Run;
  1         1  
  1         50  
13 1     1   6 use Rex::Logger;
  1         1  
  1         6  
14 1     1   34 use Rex::Commands::Fs;
  1         2  
  1         18  
15              
16 1     1   7 use base qw(Rex::Service::Base);
  1         2  
  1         394  
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 => '/etc/init.d/%s start',
27             restart => '/etc/init.d/%s restart',
28             stop => '/etc/init.d/%s stop',
29             reload => '/etc/init.d/%s reload',
30             status => '/etc/init.d/%s status',
31             action => '/etc/init.d/%s %s',
32             };
33              
34 0           return $self;
35             }
36              
37             sub ensure {
38 0     0 0   my ( $self, $service, $options ) = @_;
39              
40 0           my $what = $options->{ensure};
41              
42 0 0 0       if ( $what =~ /^stop/ ) {
    0          
43 0           $self->stop( $service, $options );
44 0           eval { i_run "rm /etc/rc*.d/S*$service"; };
  0            
45             }
46             elsif ( $what =~ /^start/ || $what =~ m/^run/ ) {
47 0           $self->start( $service, $options );
48 0           my ($runlevel) = map { /run-level (\d)/ } i_run "who -r";
  0            
49 0           ln "/etc/init.d/$service", "/etc/rc${runlevel}.d/S99$service";
50             }
51              
52 0           return 1;
53             }
54              
55             1;