/[vz-tools]/trunk/lib/VZ.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/VZ.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 42 by dpavlin, Fri Feb 8 23:53:40 2008 UTC revision 44 by dpavlin, Sat Feb 9 00:28:10 2008 UTC
# Line 7  ip2hostname Line 7  ip2hostname
7  hostname2ip  hostname2ip
8    
9  conf_veids  conf_veids
10    runscript
11    
12  vzctl  vzctl
13  vzlist  vzlist
# Line 100  sub conf_veids { Line 101  sub conf_veids {
101          return @c;          return @c;
102  }  }
103    
104    =head2 runscript
105    
106      runscript( $veid, '/path/to/script' );
107    
108    =cut
109    
110    sub runscript {
111            my ( $veid, $path ) = @_;
112    
113            open(my $fh, $path) || die "can't open $path: $!";
114            while(<$fh>) {
115                    chomp;
116                    next if (m/^\s*$/);
117                    if (/^#\s+(.+)$/) {
118                            warn ">> $1\n";
119                    } else {
120                            vzctl('exec', $veid, $_);
121                    }
122            }
123    }
124                    
125    
126  =head2 vzctl  =head2 vzctl
127    
128    vzctl('set','--something',42);    vzctl('set','--something',42);
# Line 108  sub conf_veids { Line 131  sub conf_veids {
131    
132  sub vzctl {  sub vzctl {
133          my @args = @_;          my @args = @_;
134          warn "## vzctl ", join(" ",@args), "\n";          my $a = join(' ', @args);
135            # hide passwords from output
136            $a =~ s/(--userpasswd\s+\w+:)\w+/$1********/;
137            warn "## vzctl $a\n";
138          system('vzctl',@args) == 0 or die "vzctl @args failed: $?"          system('vzctl',@args) == 0 or die "vzctl @args failed: $?"
139  }  }
140    

Legend:
Removed from v.42  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26