--- trunk/lib/VZ.pm 2008/02/09 00:28:10 44 +++ trunk/lib/VZ.pm 2009/02/02 15:10:11 59 @@ -27,6 +27,8 @@ our $vz_root = '/vz'; our $vz_conf = '/etc/vz/conf'; +$vz_root = '/var/lib/vz' if ! -e $vz_root && -e '/var/lib/vz'; + =head1 NAME VZ - helper functions for VZ tools @@ -88,7 +90,7 @@ open( my $cfgs, 'find /etc/vz/conf -maxdepth 1 -name "*.conf" |' ) || die "can't run find: $!"; while(<$cfgs>) { chomp; - if ( m#^.+/(\d+)\.conf$# ) { + if ( m{^.+/(\d+)\.conf$} ) { if ( -d "$vz_root/private/$1" ) { push @c, $1; } else { @@ -110,15 +112,18 @@ 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, $_); + if ( open(my $fh, $path) ) { + while(<$fh>) { + chomp; + next if (m/^\s*$/); + if (/^#\s+(.+)$/) { + warn ">> $1\n"; + } else { + vzctl('exec', $veid, $_); + } } + } else { + warn "can't open $path: $!"; } } @@ -153,6 +158,7 @@ my $output; + $output = {} if defined $args->{hash}; if ( ! @vzlist_fields ) { open(my $vzlist, 'vzlist -L |') || die "can't start vzlist -L: $!";