44 |
|
|
45 |
if ($arg =~ m/$RE{net}{IPv4}/) { |
if ($arg =~ m/$RE{net}{IPv4}/) { |
46 |
$ip = $arg; |
$ip = $arg; |
47 |
if ( my $h = hostname2ip($arg) ) { |
if ( my $h = ip2hostname($ip) ) { |
48 |
$hostname = $h; |
$hostname = $h; |
49 |
} |
} |
50 |
} elsif ($arg) { |
} elsif ($arg) { |
66 |
|
|
67 |
my $ve_id = sprintf('%d%03d', $ip_split[2], $ip_split[3]); |
my $ve_id = sprintf('%d%03d', $ip_split[2], $ip_split[3]); |
68 |
|
|
|
my $vz_root = '/vz'; |
|
|
|
|
|
die "need to know vz_root, and $vz_root doesn't exist: $!\n" unless (-e $vz_root); |
|
|
|
|
69 |
print "VEID: $ve_id hostname: $hostname ip: $ip\n"; |
print "VEID: $ve_id hostname: $hostname ip: $ip\n"; |
70 |
|
|
71 |
warn ">> creating directories\n"; |
warn ">> creating directories\n"; |
84 |
warn "Debian allready installed in $vz_root/private/$ve_id\n"; |
warn "Debian allready installed in $vz_root/private/$ve_id\n"; |
85 |
} |
} |
86 |
|
|
87 |
sub vzctl { |
my $conf_path = "$vz_conf/${ve_id}.conf"; |
|
my @args = @_; |
|
|
warn "## vzctl ", join(" ",@args), "\n"; |
|
|
system "vzctl", @args; |
|
|
} |
|
|
|
|
|
my $conf_path = "/etc/vz/conf/${ve_id}.conf"; |
|
88 |
warn ">> creating configuration file $conf_path\n"; |
warn ">> creating configuration file $conf_path\n"; |
89 |
|
|
90 |
if (-e $conf_path) { |
if (-e $conf_path) { |
191 |
vzctl('exec', $ve_id, "useradd --create-home $login"); |
vzctl('exec', $ve_id, "useradd --create-home $login"); |
192 |
vzctl('set', $ve_id, '--userpasswd', "$login:$passwd" ); |
vzctl('set', $ve_id, '--userpasswd', "$login:$passwd" ); |
193 |
} |
} |
194 |
|
|
195 |
|
print "OK: $ve_id created\n"; |