upgradeprovision: Allow script to be called with pydoc
authorMatthieu Patou <mat@matws.net>
Sun, 21 Feb 2010 18:28:35 +0000 (21:28 +0300)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 1 Mar 2010 02:20:36 +0000 (03:20 +0100)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
source4/scripting/bin/upgradeprovision

index 5fe71c4f04083056b64b956dcb202b3a7b6c9ca7..3ce6ae422a52d8e44a14278b18e32b004ae65ec5 100755 (executable)
@@ -722,43 +722,45 @@ def update_machine_account_password(paths, creds, session, names):
 
 def setup_path(file):
        return os.path.join(setup_dir, file)
-
-# From here start the big steps of the program
-# First get files paths
-paths=get_paths(param,smbconf=smbconf)
-paths.setup = setup_dir
-# Guess all the needed names (variables in fact) from the current
-# provision.
-
-names = find_provision_key_parameters(param, creds, session, paths, smbconf)
-if not sanitychecks(creds,session,names,paths):
-       message(SIMPLE,"Sanity checks for the upgrade fails, checks messages and correct it before rerunning upgradeprovision")
-       sys.exit(1)
-# Let's see them
-print_provision_key_parameters(names)
-# With all this information let's create a fresh new provision used as reference
-message(SIMPLE,"Creating a reference provision")
-provisiondir = tempfile.mkdtemp(dir=paths.private_dir, prefix="referenceprovision")
-newprovision(names, setup_dir, creds, session, smbconf, provisiondir, messageprovision)
-# Get file paths of this new provision
-newpaths = get_paths(param, targetdir=provisiondir)
-populate_backlink(newpaths, creds, session,names.schemadn)
-populate_dnsyntax(newpaths, creds, session,names.schemadn)
-# Check the difference
-update_basesamdb(newpaths, paths,names)
-
-if opts.full:
-       update_samdb(newpaths, paths, creds, session, names)
-update_secrets(newpaths, paths, creds, session)
-update_privilege(newpaths, paths)
-update_machine_account_password(paths, creds, session, names)
-# SD should be created with admin but as some previous acl were so wrong that admin can't modify them we have first
-# to recreate them with the good form but with system account and then give the ownership to admin ...
-admin_session_info = admin_session(lp, str(names.domainsid))
-message(SIMPLE,"Updating SD")
-update_sd(paths, creds, session,names)
-update_sd(paths, creds, admin_session_info, names)
-check_updated_sd(newpaths, paths, creds, session, names)
-message(SIMPLE,"Upgrade finished !")
-# remove reference provision now that everything is done !
-rmall(provisiondir)
+cmd = os.environ["_"]
+m=re.match('(^|.*/)pydoc$',cmd)
+if not m:
+       # From here start the big steps of the program
+       # First get files paths
+       paths=get_paths(param,smbconf=smbconf)
+       paths.setup = setup_dir
+       # Guess all the needed names (variables in fact) from the current
+       # provision.
+
+       names = find_provision_key_parameters(param, creds, session, paths, smbconf)
+       if not sanitychecks(creds,session,names,paths):
+               message(SIMPLE,"Sanity checks for the upgrade fails, checks messages and correct it before rerunning upgradeprovision")
+               sys.exit(1)
+       # Let's see them
+       print_provision_key_parameters(names)
+       # With all this information let's create a fresh new provision used as reference
+       message(SIMPLE,"Creating a reference provision")
+       provisiondir = tempfile.mkdtemp(dir=paths.private_dir, prefix="referenceprovision")
+       newprovision(names, setup_dir, creds, session, smbconf, provisiondir, messageprovision)
+       # Get file paths of this new provision
+       newpaths = get_paths(param, targetdir=provisiondir)
+       populate_backlink(newpaths, creds, session,names.schemadn)
+       populate_dnsyntax(newpaths, creds, session,names.schemadn)
+       # Check the difference
+       update_basesamdb(newpaths, paths,names)
+
+       if opts.full:
+               update_samdb(newpaths, paths, creds, session, names)
+       update_secrets(newpaths, paths, creds, session)
+       update_privilege(newpaths, paths)
+       update_machine_account_password(paths, creds, session, names)
+       # SD should be created with admin but as some previous acl were so wrong that admin can't modify them we have first
+       # to recreate them with the good form but with system account and then give the ownership to admin ...
+       admin_session_info = admin_session(lp, str(names.domainsid))
+       message(SIMPLE,"Updating SD")
+       update_sd(paths, creds, session,names)
+       update_sd(paths, creds, admin_session_info, names)
+       check_updated_sd(newpaths, paths, creds, session, names)
+       message(SIMPLE,"Upgrade finished !")
+       # remove reference provision now that everything is done !
+       rmall(provisiondir)