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

Annotation of /trunk/vz-remove.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (hide annotations)
Fri Feb 8 20:03:16 2008 UTC (16 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 954 byte(s)
remove VE
1 dpavlin 36 #!/usr/bin/perl -w
2    
3     use strict;
4     use Shell qw/rm vzlist/;
5    
6     my $vz = '/vz';
7     my $conf = '/etc/vz/conf';
8    
9     my $VEID = shift @ARGV;
10    
11     sub vzlist_config {
12     my @c;
13     open( my $cfgs, 'find /etc/vz/conf -maxdepth 1 -name "*.conf" |' ) || die "can't run find: $!";
14     while(<$cfgs>) {
15     chomp;
16     if ( m#^.+/(\d+)\.conf$# ) {
17     if ( -d "$vz/private/$1" ) {
18     push @c, $1;
19     } else {
20     warn "WARNING: have config for $1 but no private directory\n";
21     }
22     } else {
23     warn "SKIPPED: $_\n";
24     }
25     }
26     return @c;
27     }
28    
29     die "Usage: $0 VEID\n\n", join("\n",vzlist_config()),"\n" unless $VEID;
30    
31     my $c = "$conf/$VEID.conf";
32     if ( -e $c ) {
33     unlink $c || die "can't remove $c: $!";
34     } else {
35     warn "WARNING: configuration file $c doesn't exist\n";
36     }
37    
38     foreach my $p ( qw/root private/ ) {
39     my $c = "$vz/$p/$VEID";
40     if ( -e $c ) {
41     rm('-Rf', $c);
42     die "can't remove $c: $!" if -e $c;
43     } else {
44     warn "WARNING: directory $c doesn't exist\n";
45     }
46     }
47    
48     print "OK: $VEID removed\n";

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26