| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use FindBin qw( $Bin $RealBin ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Tie::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | exit 0 unless $ENV{dan} || $ENV{box} || $ENV{def}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"def"}
$ENV{"dan"} or $ENV{"box"}
MC/DC0%0/3
$ENV{"dan"} or $ENV{"box"} or $ENV{"def"}
$ENV{"dan"}
$ENV{"box"}
$ENV{"def"}
Truth table25%1/4
A or B or C
A= $ENV{"dan"}B= $ENV{"box"}C= $ENV{"def"}
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | sub mydanpath | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mydanpath: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | if ( my $path = $ENV{mydan} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | { | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my @p = split /\//, $path; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | die "The directory name must be mydan. example: /tmp/abc/mydan\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | unless $p[-1] eq 'mydan'; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | return $path; | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | for ( $RealBin, $ENV{PERL_PATH}, $^X ) | |||||||||||||||||||||||||||||||||||||||||
| 18 | { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | next unless $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my @p = split /\//, $_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | while ( @p ) { $p[-1] eq 'mydan' ? last : pop @p; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return join( '/', @p ) if @p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return '/opt/mydan'; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $mydan = mydanpath(); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | system "mkdir -p '$mydan'" unless -e $mydan; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $perl = $ENV{PERL_PATH} || $^X; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'PERL_PATH'} || $^X
MC/DC0%0/2
$ENV{'PERL_PATH'} || $^X
$ENV{'PERL_PATH'}
$^X
Truth table0%0/3
A || B
A= $ENV{'PERL_PATH'}B= $^X
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub mysystem | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mysystem: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | die "$cmd fail:$!" if system $cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub repl | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
repl: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ( $type, %reg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | for my $file ( `find $type -type f` ) | |||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | chomp $file; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | tie my ( @file ), 'Tie::File', $file; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if( @file ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if( %reg ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | while( my ( $k, $v ) = each %reg ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | map{ $_ =~ s/$k/$v/g }@file; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | else | ||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $file[0] = "#!$perl$1" if $file[0] =~ /#![^#]*perl(.*$)/o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | warn "$file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | untie @file; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if( $ENV{dan} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | mysystem "rsync -a dan/ dan.i/"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | repl( 'dan.i' ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | mysystem "rsync -a dan.i/ '$mydan/dan/'"; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if( $ENV{box} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | mysystem "rsync -a box/ box.i/"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | mysystem "rsync -a dan/node/ box.i/node/"; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | map { mysystem "rsync -a dan/tools/$_ box.i/tools/" } qw(range mcmd mssh expect vssh go rsync alias unalias sync config whois gateway git gitrsync diskSpaceControl supervisor secure reborn check fastmd5 os ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my @sed = ( | |||||||||||||||||||||||||||||||||||||||||
| 83 | 'box.i/tools/vssh' => [ 'logname', 'id -un' ], | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 'box.i/tools/vssh' => [ 'MYDan::VSSH::Execute::dan=1', 'MYDan::VSSH::Execute::dan=0' ], | ||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | while( my ( $f, $s ) = splice @sed, 0, 2 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | tie my ( @file ), 'Tie::File', $f; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | map{ s/$s->[0]/$s->[1]/g }@file; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | untie @file; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | repl( 'box.i' ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | mysystem "rsync -a box.i/ '$mydan/box/'"; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if( $ENV{dan} || $ENV{box} || $ENV{bin} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}
$ENV{"dan"} or $ENV{"box"}
MC/DC0%0/3
$ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}
$ENV{"dan"}
$ENV{"box"}
$ENV{"bin"}
Truth table0%0/4
A or B or C
A= $ENV{"dan"}B= $ENV{"box"}C= $ENV{"bin"}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | mysystem "rsync -a bin/ bin.i/"; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | repl( 'bin.i' ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | mysystem( "ln -fsn mydan bin.i/$ENV{nickname}" ) | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if $ENV{nickname} && $ENV{nickname} =~ /^[a-z0-9]+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/
MC/DC0%0/2
$ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/
$ENV{"nickname"}
$ENV{"nickname"} =~ /^[a-z0-9]+$/
Truth table0%0/3
A and B
A= $ENV{"nickname"}B= $ENV{"nickname"} =~ /^[a-z0-9]+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | mysystem "rsync -a bin.i/ '$mydan/bin/'"; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | mysystem( "mkdir '$mydan/tmp' && chmod a+rwx,o+t '$mydan/tmp'" ) unless -e "$mydan/tmp"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | mysystem( "mkdir -p '$mydan/var/run/filecache' && chmod a+rwx '$mydan/var/run/filecache'" ) unless -e "$mydan/var/run/filecache"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if( $ENV{def} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | mysystem( "rsync -a def/ def.i/" ); | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | repl( 'def.i', MYDanROOT => $mydan ); | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | mysystem( "rsync -a def.i/ '$mydan/'" ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||