1 |
diff -up smeserver-ddclient-1.0.0/root/etc/e-smith/db/domains/migrate/80ddclient.extrasmigrate smeserver-ddclient-1.0.0/root/etc/e-smith/db/domains/migrate/80ddclient |
2 |
--- smeserver-ddclient-1.0.0/root/etc/e-smith/db/domains/migrate/80ddclient.extrasmigrate 2013-12-30 14:17:00.000000000 -0500 |
3 |
+++ smeserver-ddclient-1.0.0/root/etc/e-smith/db/domains/migrate/80ddclient 2013-12-30 14:18:10.000000000 -0500 |
4 |
@@ -0,0 +1,64 @@ |
5 |
+{ |
6 |
+my $filename = '/home/e-smith/db/extras'; |
7 |
+return 0 |
8 |
+unless (-e $filename); |
9 |
+ |
10 |
+ |
11 |
+use esmith::ConfigDB; |
12 |
+ |
13 |
+##use db domain or die if doesn't exist |
14 |
+my $domaindb = esmith::ConfigDB->open('/home/e-smith/db/domains'); |
15 |
+ |
16 |
+##use db extras or die if doesn't exist |
17 |
+my $edb = esmith::ConfigDB->open($filename); |
18 |
+ |
19 |
+ if (defined $edb) |
20 |
+ { |
21 |
+ foreach my $extradomain ($edb->get_all_by_prop(type=>'ddhost')) |
22 |
+ { |
23 |
+ my $currentdom = $extradomain->key; |
24 |
+ my $descddhost = $edb->get_prop("$currentdom", "desc") || "ddhost migrated domain"; |
25 |
+ my $dnsddhost = $edb->get_prop("$currentdom", "dns"); |
26 |
+ my $mxddhost = $edb->get_prop("$currentdom", "mx"); |
27 |
+ my $passwordddhost = $edb->get_prop("$currentdom", "password"); |
28 |
+ my $login = $edb->get_prop("$currentdom", "login"); |
29 |
+ |
30 |
+ $domaindb->new_record( "$currentdom" ); |
31 |
+ $domaindb->set_value( "$currentdom" , "domain" ); |
32 |
+ $domaindb->set_prop( "$currentdom" , "Description" , "$descddhost" ); |
33 |
+ $domaindb->set_prop( "$currentdom" , "dns" , "$dnsddhost" ) if defined $dnsddhost; |
34 |
+ $domaindb->set_prop( "$currentdom" , "mx" , "$mxddhost") if defined $mxddhost; |
35 |
+ $domaindb->set_prop( "$currentdom" , "password" , "$passwordddhost" ) if defined $passwordddhost; |
36 |
+ $domaindb->set_prop( "$currentdom" , "login" , "$login" ) if defined $login; |
37 |
+ # followings set defaults values as a domain pointing to Primary ibay |
38 |
+ # as even if they are not configured they will point there ! |
39 |
+ # Nameservers are defined as internet, as they are dynamic domains, |
40 |
+ # if admin wants to point as a localhost, he just has to do it in the manager |
41 |
+ $domaindb->set_prop( "$currentdom" , "SystemPrimaryDomain" , "no" ); |
42 |
+ $domaindb->set_prop( "$currentdom" , "Removable" , "yes" ); |
43 |
+ $domaindb->set_prop( "$currentdom" , "Nameservers" , "internet" ); |
44 |
+ $domaindb->set_prop( "$currentdom" , "Content" , "Primary" ); |
45 |
+ } |
46 |
+ |
47 |
+ foreach my $extradomain ($edb->get_all_by_prop(type=>'domain')) |
48 |
+ |
49 |
+ { |
50 |
+ my $currentdom = $extradomain->key; |
51 |
+ # commented as we rather keep description already in domain |
52 |
+ #my $descdomain = $edb->get_prop("$currentdom", "desc"); |
53 |
+ my $dnsdomain = $edb->get_prop("$currentdom", "dns"); |
54 |
+ my $mxdomain = $edb->get_prop("$currentdom", "mx"); |
55 |
+ my $passworddomain = $edb->get_prop("$currentdom", "password"); |
56 |
+ my $login = $edb->get_prop("$currentdom", "login"); |
57 |
+ |
58 |
+ #$domaindb->set_prop( "$currentdom" , "desc", "$descdomain" ); |
59 |
+ $domaindb->set_prop( "$currentdom" , "dns" , "$dnsdomain" ) if defined $dnsdomain; |
60 |
+ $domaindb->set_prop( "$currentdom" , "mx" , "$mxdomain" ) if defined $mxdomain; |
61 |
+ $domaindb->set_prop( "$currentdom" , "password" , "$passworddomain" ) if defined $passworddomain; |
62 |
+ $domaindb->set_prop( "$currentdom" , "login" , "$login" ) if defined $login; |
63 |
+ } |
64 |
+ |
65 |
+system ("/bin/mv $filename /home/e-smith/db/extras-migrated"); |
66 |
+ |
67 |
+ } |
68 |
+} |