-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathtransfer.cgi
executable file
·84 lines (74 loc) · 2.25 KB
/
transfer.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/local/bin/perl
# Actually transfer a domain to another system
require './virtual-server-lib.pl';
&ReadParse();
&error_setup($text{'transfer_err'});
$d = &get_domain($in{'dom'});
&can_move_domain($d) || &error($text{'transfer_ecannot'});
# Validate inputs
my @hosts = &get_transfer_hosts();
if ($in{'host_mode'}) {
# Use an old host
my ($h) = grep { $_->[0] eq $in{'oldhost'} } @hosts;
$h || &error($text{'transfer_eoldhost'});
$host = $h->[0];
$pass = $h->[1];
$proto = $h->[2] || 'ssh';
$user = $h->[3] || 'root';
}
else {
# Entering a new host
$in{'host'} =~ /^\S+$/ || &error($text{'transfer_ehost'});
($hostname) = split(/:/, $in{'host'});
&to_ipaddress($hostname) || &to_ip6address($hostname) ||
&error($text{'transfer_ehost2'});
$host = $in{'host'};
$user = $in{'hostuser'};
$pass = $in{'hostpass'};
$proto = $in{'proto'};
if ($in{'savehost'}) {
my ($h) = grep { $_->[0] eq $in{'host'} } @hosts;
if ($h) {
$h->[1] = $pass;
$h->[2] = $proto;
$h->[3] = $user;
}
else {
push(@hosts, [ $host, $pass, $proto, $user ]);
}
&save_transfer_hosts(@hosts);
}
}
my $err = &validate_transfer_host($d, $host, $user, $pass, $proto,
$in{'overwrite'});
&error($err) if ($err);
# Cannot both delete and replicate
if ($in{'delete'} && $in{'replication'}) {
&error($text{'transfer_ereplication'});
}
&ui_print_unbuffered_header(&domain_in($d), $text{'transfer_title'}, "");
# Call the transfer function
my @subs = ( &get_domain_by("parent", $d->{'id'}),
&get_domain_by("alias", $d->{'id'}) );
&$first_print(&text(@subs ? 'transfer_doing2' : 'transfer_doing',
$d->{'dom'}, $host, scalar(@subs)));
&$indent_print();
$ok = &transfer_virtual_server($d, $host, $user, $pass, $proto,
$in{'delete'},
$in{'overwrite'} && !$in{'delete'},
$in{'replication'}, $in{'output'});
&$outdent_print();
if ($ok) {
&$second_print($text{'setup_done'});
}
else {
&$second_print($text{'transfer_failed'});
}
&run_post_actions();
&webmin_log("transfer", "domain", $d->{'dom'}, $d);
# Call any theme post command
if (defined(&theme_post_save_domain)) {
&theme_post_save_domain($d, $in{'delete'} == 2 ? 'delete' : 'modify');
}
&ui_print_footer(&domain_footer_link($d),
"", $text{'index_return'});