| 1 | package Ubic::Run; | ||||||||||||||||||
| 2 | 33 | $Ubic::Run::VERSION = '1.59'; | |||||||||||||||||
| 3 | 33 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 33 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | # ABSTRACT: really simple way to write init scripts | ||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | 33 | ▶ | use Ubic::Cmd; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 33 | ▶ | use Getopt::Long; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 33 | ▶ | use Pod::Usage; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | sub import { | ||||||||||||||||||
| 14 | 33 | ▶ | my $class = shift; | ||||||||||||||||
|
Subroutine
import: called CC=9 SCAR=22.0
| |||||||||||||||||||
| 15 | 33 | my ($name) = @_; | |||||||||||||||||
| 16 | 33 | ▶ | unless (defined $name) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 17 | 29 | ▶ | if ( $0 =~ m{^/etc/init\.d/(.+)$} ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 18 | 12 | $name = $1; | |||||||||||||||||
| 19 | } | ||||||||||||||||||
| 20 | elsif ( $0 =~ m{^/etc/rc\d\.d/(?:K|S)\d+(.+)$} ) { | ||||||||||||||||||
| 21 | 8 | $name = $1; | |||||||||||||||||
| 22 | } | ||||||||||||||||||
| 23 | elsif ( $0 =~ m{^/etc/rc\.d/init\.d/(.+)$} ) { | ||||||||||||||||||
| 24 | 8 | $name = $1; | |||||||||||||||||
| 25 | } | ||||||||||||||||||
| 26 | else { | ||||||||||||||||||
| 27 | 1 | die "Strange \$0: $0"; | |||||||||||||||||
| 28 | } | ||||||||||||||||||
| 29 | } | ||||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | 32 | my $force; | |||||||||||||||||
| 32 | 32 | ▶ | GetOptions( | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 33 | 'f|force' => \$force, | ||||||||||||||||||
| 34 | ) or die "Unknown option specified"; | ||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 32 | my ($command, @args) = @ARGV; | |||||||||||||||||
| 37 | 32 | my @names; | |||||||||||||||||
| 38 | 32 | ▶ | if (@args) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 39 | 4 | @names = map { "$name.$_" } @args; | |||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | else { | ||||||||||||||||||
| 42 | 28 | @names = ($name); | |||||||||||||||||
| 43 | } | ||||||||||||||||||
| 44 | 32 | ▶ | Ubic::Cmd->run({ | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 45 | name => \@names, | ||||||||||||||||||
| 46 | ($command ? (command => $command) : ()), | ||||||||||||||||||
| 47 | ($force ? (force => $force) : ()), | ||||||||||||||||||
| 48 | }); | ||||||||||||||||||
| 49 | } | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 33 | 1; | |||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||