85 |
my ( $from, $to ) = @_; |
my ( $from, $to ) = @_; |
86 |
return if $action ne 'create'; |
return if $action ne 'create'; |
87 |
warn "rsync $from -> $to\n"; |
warn "rsync $from -> $to\n"; |
88 |
rsync('-raSHAD', "$from/", "$to/" ); |
rsync('-raSHAD', '--delete', "$from/", "$to/" ); |
89 |
} |
} |
90 |
|
|
91 |
if ( $vz_lv ) { |
if ( $vz_lv ) { |
169 |
|
|
170 |
my $note = "# modified by $0\n"; |
my $note = "# modified by $0\n"; |
171 |
|
|
172 |
|
my $ve_clone_ip; |
173 |
|
|
174 |
sub fix_ip { |
sub fix_ip { |
175 |
my $ip = shift; |
my $ip = shift; |
176 |
$ip =~ s/['"]//g; |
$ip =~ s/['"]//g; |
177 |
$ip =~ s/^\d+\./10./; |
# $ip =~ s/^\d+\./10./; |
178 |
|
$ip =~ s/^\d+\.\d+\./192.168./; |
179 |
warn "$CVEID new IP number: $ip\n"; |
warn "$CVEID new IP number: $ip\n"; |
180 |
|
$ve_clone_ip = $ip; |
181 |
return $note . qq{IP_ADDRESS="$ip"}; |
return $note . qq{IP_ADDRESS="$ip"}; |
182 |
} |
} |
183 |
|
|
192 |
open(my $o, '<', "$conf/$VEID.conf") || die "can't open $conf/$VEID.conf: $!"; |
open(my $o, '<', "$conf/$VEID.conf") || die "can't open $conf/$VEID.conf: $!"; |
193 |
open(my $n, '>', "$conf/$CVEID.conf") || die "can't open $conf/$CVEID.conf: $!"; |
open(my $n, '>', "$conf/$CVEID.conf") || die "can't open $conf/$CVEID.conf: $!"; |
194 |
while(<$o>) { |
while(<$o>) { |
195 |
s!^HOSTNAME=(.*)$!fix_hostname($1)!ie; |
s{^HOSTNAME=(.*)$}{fix_hostname($1)}ie; |
196 |
s!^IP_ADDRESS=(.*)$!fix_ip($1)!ie; |
s{^IP_ADDRESS=(.*)$}{fix_ip($1)}ie; |
197 |
s!^(ONBOOT=).*$!# modified by $0\n$1"no"!i; |
s{^(ONBOOT=).*$}{# modified by $0\n$1"no"}i; |
198 |
print $n $_; |
print $n $_; |
199 |
} |
} |
200 |
|
|
201 |
print "\nPlease review config file: $conf/$CVEID.conf\nAdd NAT for new VE with: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\nStart clone of $VEID with: vzctl start $CVEID\n" |
print "\nPlease review config file: $conf/$CVEID.conf\nAdd NAT for new VE with: iptables -t nat -A POSTROUTING -s $ve_clone_ip -o eth0 -j MASQUERADE\nStart clone of $VEID with: vzctl start $CVEID\n" |