summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-10 10:29:26 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:49:07 +0100
commit1a562591ec8abfdbb0ffcd1dfb14f78655ff0a42 (patch)
treea856d8c839315b8620c6ab7dae6aee36aaeb78e2
parentb414ac505282f5a2a59c7580a19dfbd86489676e (diff)
downloadsamba-1a562591ec8abfdbb0ffcd1dfb14f78655ff0a42.tar.gz
samba-1a562591ec8abfdbb0ffcd1dfb14f78655ff0a42.tar.bz2
samba-1a562591ec8abfdbb0ffcd1dfb14f78655ff0a42.zip
r26370: Import upgrade script in Python.
(This used to be commit 277f2165241dafe68e31a8197194c94d9d4a535e)
-rwxr-xr-xsource4/setup/upgrade.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/source4/setup/upgrade.py b/source4/setup/upgrade.py
new file mode 100755
index 0000000000..e5e6d2c832
--- /dev/null
+++ b/source4/setup/upgrade.py
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+#
+# Upgrade from Samba3
+# Copyright Jelmer Vernooij 2005-2007
+# Released under the GNU GPL v3 or later
+#
+import getopt
+import optparse
+import samba.options
+
+parser = optparse.OptionParser("upgrade [options]")
+parser.add_option_group(options.SambaOptions(parser))
+parser.add_option_group(options.VersionOptions(parser))
+parser.add_option_group(options.CredentialsOptions(parser))
+parser.add_option("--realm", type="string", metavar="REALM", help="set realm")
+parser.add_option("--quiet", help="Be quiet")
+parser.add_option("--verify", help="Verify resulting configuration")
+parser.add_option("--blank",
+ help="do not add users or groups, just the structure")
+parser.add_option("--targetdir", type="string", metavar="DIR",
+ help="Set target directory")
+
+def message(text):
+ """Print a message if quiet is not set."""
+ if opts.quiet:
+ print text
+
+message("Reading Samba3 databases and smb.conf\n")
+samba3 = samba3_read(options.ARGV[0], options.ARGV[1])
+
+message("Provisioning\n")
+subobj = upgrade_provision(samba3)
+if options.targetdir is not None:
+ paths = ProvisionPaths()
+ paths.smbconf = os.path.join(options.targetdir, "smb.conf")
+ ldbs = ["hklm","hkcr","hku","hkcu","hkpd","hkpt","samdb","rootdse","secrets","wins"]
+ for n in ldbs:
+ paths[n] = sprintf("tdb://%s/%s.ldb", options.targetdir, n)
+ paths.dns = os.path.join(options.targetdir, "dns.zone")
+else:
+ paths = provision_default_paths(subobj)
+
+creds = options.get_credentials()
+system_session = system_session()
+paths = provision_default_paths(subobj)
+
+if options.realm:
+ subobj.realm = options.realm
+
+provision(lp, subobj, message, options.blank, paths, system_session, creds, undefined)
+
+ret = upgrade(subobj,samba3,message,paths, system_session, creds)
+if ret > 0:
+ message("Failed to import %d entries\n", ret)
+else:
+ provision_dns(subobj, message, paths, system_session, creds)
+ message("All OK\n")
+
+if options.verify:
+ message("Verifying...\n")
+ ret = upgrade_verify(subobj, samba3, paths, message)