svn commit: samba r5048 - in branches/SAMBA_4_0/source/script: .
tridge at samba.org
tridge at samba.org
Thu Jan 27 22:32:44 GMT 2005
Author: tridge
Date: 2005-01-27 22:32:44 +0000 (Thu, 27 Jan 2005)
New Revision: 5048
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5048
Log:
made the provision.pl script much less error prone (you don't need to
rename a bunch of files)
Modified:
branches/SAMBA_4_0/source/script/provision.pl
Changeset:
Modified: branches/SAMBA_4_0/source/script/provision.pl
===================================================================
--- branches/SAMBA_4_0/source/script/provision.pl 2005-01-27 20:50:17 UTC (rev 5047)
+++ branches/SAMBA_4_0/source/script/provision.pl 2005-01-27 22:32:44 UTC (rev 5048)
@@ -186,6 +186,23 @@
die "ERROR: Uknown substitution variable $var\n";
}
+
+####################################################################
+# substitute all variables in a string
+sub apply_substitutions($)
+{
+ my $data = shift;
+ my $res = "";
+ while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
+ my $sub = substitute($2);
+ $res .= "$1$sub";
+ $data = $3;
+ }
+ $res .= $data;
+ return $res;
+}
+
+
#####################################################################
# write a string into a file
sub FileSave($$)
@@ -365,123 +382,62 @@
print "chose random Administrator password '$opt_adminpass'\n";
}
-my $res = "";
-
-print "applying substitutions ...\n";
-
-while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
- my $sub = substitute($2);
- $res .= "$1$sub";
- $data = $3;
-}
-$res .= $data;
-
-print "saving ldif to newsam.ldif ...\n";
-
-FileSave("newsam.ldif", $res);
-
-unlink("newsam.ldb");
-
-print "creating newsam.ldb ...\n";
-
# allow provisioning to be run from the source directory
$ENV{"PATH"} .= ":bin";
-system("ldbadd -H newsam.ldb newsam.ldif");
-print "done\n";
+my $res = apply_substitutions($data);
-$data = FileLoad("rootdse.ldif") || die "Unable to load rootdse.ldif\n";
+my $newdb = "newdb." . int(rand(1000));
-$res = "";
+print "Putting new database files in $newdb\n";
-print "applying substitutions ...\n";
+mkdir($newdb) || die "Unable to create temporary directory $newdb\n";
-while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
- my $sub = substitute($2);
- $res .= "$1$sub";
- $data = $3;
-}
-$res .= $data;
+FileSave("$newdb/sam.ldif", $res);
-print "saving ldif to newrootdse.ldif ...\n";
+print "creating $newdb/sam.ldb ...\n";
-FileSave("newrootdse.ldif", $res);
+system("ldbadd -H $newdb/sam.ldb $newdb/sam.ldif") == 0 || die "Failed to create sam.ldb\n";
-unlink("newrootdse.ldb");
+$data = FileLoad("rootdse.ldif") || die "Unable to load rootdse.ldif\n";
-print "creating newrootdse.ldb ...\n";
+$res = apply_substitutions($data);
-system("ldbadd -H newrootdse.ldb newrootdse.ldif");
+FileSave("$newdb/rootdse.ldif", $res);
-print "done\n";
+print "creating $newdb/rootdse.ldb ...\n";
+system("ldbadd -H $newdb/rootdse.ldb $newdb/rootdse.ldif") == 0 || die "Failed to create rootdse.ldb\n";
+
$data = FileLoad("secrets.ldif") || die "Unable to load secrets.ldif\n";
-$res = "";
+$res = apply_substitutions($data);
-print "applying substitutions ...\n";
+FileSave("$newdb/secrets.ldif", $res);
-while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
- my $sub = substitute($2);
- $res .= "$1$sub";
- $data = $3;
-}
-$res .= $data;
+print "creating $newdb/secrets.ldb ...\n";
-print "saving ldif to newsecrets.ldif ...\n";
+system("ldbadd -H $newdb/secrets.ldb $newdb/secrets.ldif") == 0 || die "Failed to create secrets.ldb\n";
-FileSave("newsecrets.ldif", $res);
-
-unlink("newsecrets.ldb");
-
-print "creating newsecrets.ldb ...\n";
-
-system("ldbadd -H newsecrets.ldb newsecrets.ldif");
-
-print "done\n";
-
-print "generating dns zone file ...\n";
-
$data = FileLoad("provision.zone") || die "Unable to load provision.zone\n";
-$res = "";
+$res = apply_substitutions($data);
-print "applying substitutions ...\n";
+print "saving dns zone to $newdb/dns.zone ...\n";
-while ($data =~ /(.*?)\$\{(\w*)\}(.*)/s) {
- my $sub = substitute($2);
- $res .= "$1$sub";
- $data = $3;
-}
-$res .= $data;
-
-print "saving dns zone to newdns.zone ...\n";
-
FileSave("$dnsdomain.zone", $res);
-print "done\n";
+print "creating $newdb/hklm.ldb ... \n";
-unlink("newhklm.ldb");
+system("ldbadd -H $newdb/hklm.ldb hklm.ldif") == 0 || die "Failed to create hklm.ldb\n";
-print "creating newhklm.ldb ... \n";
-
-system("ldbadd -H newhklm.ldb hklm.ldif");
-
-print "done\n";
-
print "
Installation:
-- Please move newsam.ldb to sam.ldb in the private/ directory of your
+- Please move $newdb/*.ldb to the private/ directory of your
Samba4 installation
-- Please move newrootdse.ldb to rootdse.ldb in the private/ directory
- of your Samba4 installation
-- Please move newsecrets.ldb to secrets.ldb in the private/ directory
- of your Samba4 installation
-- Please move newhklm.ldb to hklm.ldb in the private/ directory
- of your Samba4 installation
-- Please use $dnsdomain.zone to in BIND dns server
+- Please use $newdb/dnsdomain.zone in BIND on your dns server
";
More information about the samba-cvs
mailing list