--- trunk/lib/VZ.pm 2008/02/08 23:53:40 42 +++ trunk/lib/VZ.pm 2008/02/09 00:28:10 44 @@ -7,6 +7,7 @@ hostname2ip conf_veids +runscript vzctl vzlist @@ -100,6 +101,28 @@ return @c; } +=head2 runscript + + runscript( $veid, '/path/to/script' ); + +=cut + +sub runscript { + my ( $veid, $path ) = @_; + + open(my $fh, $path) || die "can't open $path: $!"; + while(<$fh>) { + chomp; + next if (m/^\s*$/); + if (/^#\s+(.+)$/) { + warn ">> $1\n"; + } else { + vzctl('exec', $veid, $_); + } + } +} + + =head2 vzctl vzctl('set','--something',42); @@ -108,7 +131,10 @@ sub vzctl { my @args = @_; - warn "## vzctl ", join(" ",@args), "\n"; + my $a = join(' ', @args); + # hide passwords from output + $a =~ s/(--userpasswd\s+\w+:)\w+/$1********/; + warn "## vzctl $a\n"; system('vzctl',@args) == 0 or die "vzctl @args failed: $?" }