"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "samba-4.0.0alpha5/source/setup/upgrade" of archive samba-4.0.0alpha5.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 #!/usr/bin/python
    2 #
    3 #	Upgrade from Samba3
    4 #	Copyright Jelmer Vernooij 2005-2007
    5 #	Released under the GNU GPL v3 or later
    6 #
    7 import getopt
    8 import optparse
    9 import os, sys
   10 
   11 # Find right directory when running from source tree
   12 sys.path.insert(0, "bin/python")
   13 
   14 import samba
   15 import samba.getopt as options
   16 from samba import param
   17 from samba.auth import system_session
   18 
   19 parser = optparse.OptionParser("upgrade [options] <libdir> <smbconf>")
   20 sambaopts = options.SambaOptions(parser)
   21 parser.add_option_group(sambaopts)
   22 parser.add_option_group(options.VersionOptions(parser))
   23 credopts = options.CredentialsOptions(parser)
   24 parser.add_option_group(credopts)
   25 parser.add_option("--setupdir", type="string", metavar="DIR", 
   26 		help="directory with setup files")
   27 parser.add_option("--realm", type="string", metavar="REALM", help="set realm")
   28 parser.add_option("--quiet", help="Be quiet")
   29 parser.add_option("--blank", 
   30 		help="do not add users or groups, just the structure")
   31 parser.add_option("--targetdir", type="string", metavar="DIR", 
   32 		          help="Set target directory")
   33 
   34 opts, args = parser.parse_args()
   35 
   36 def message(text):
   37     """Print a message if quiet is not set."""
   38     if opts.quiet:
   39         print text
   40 
   41 if len(args) < 1:
   42     parser.print_usage()
   43     sys.exit(1)
   44 from samba.samba3 import Samba3
   45 message("Reading Samba3 databases and smb.conf\n")
   46 libdir = args[0]
   47 if not os.path.isdir(libdir):
   48     print "error: %s is not a directory"
   49     sys.exit(1)
   50 if len(args) > 1:
   51     smbconf = args[1]
   52 else:
   53     smbconf = os.path.join(libdir, "smb.conf")
   54 samba3 = Samba3(libdir, smbconf)
   55 
   56 from samba.upgrade import upgrade_provision
   57 
   58 message("Provisioning\n")
   59 
   60 setup_dir = opts.setupdir
   61 if setup_dir is None:
   62 	setup_dir = "setup"
   63 
   64 lp = sambaopts.get_loadparm()
   65 smbconf = lp.configfile()
   66 creds = credopts.get_credentials(lp)
   67 
   68 upgrade_provision(samba3, setup_dir, message, credentials=creds, session_info=system_session(), 
   69                   smbconf=smbconf, targetdir=opts.targetdir)