source: trunk/server/source4/setup/upgrade_from_s3

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.4 KB
Line 
1#!/usr/bin/env python
2#
3# Upgrade from Samba3
4# Copyright Jelmer Vernooij 2005-2007
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19import logging
20import optparse
21import os, sys
22
23# Find right directory when running from source tree
24sys.path.insert(0, "bin/python")
25
26import samba
27import samba.getopt as options
28from samba.auth import system_session
29from samba.upgrade import upgrade_provision
30from samba.samba3 import Samba3
31parser = optparse.OptionParser("upgrade_from_s3 [options] <libdir> <smbconf>")
32sambaopts = options.SambaOptions(parser)
33parser.add_option_group(sambaopts)
34parser.add_option_group(options.VersionOptions(parser))
35credopts = options.CredentialsOptions(parser)
36parser.add_option_group(credopts)
37parser.add_option("--quiet", help="Be quiet")
38parser.add_option("--blank",
39 help="do not add users or groups, just the structure")
40parser.add_option("--targetdir", type="string", metavar="DIR",
41 help="Set target directory")
42
43opts, args = parser.parse_args()
44
45logger = logging.getLogger("upgrade")
46logger.addHandler(logging.StreamHandler(sys.stdout))
47if opts.quiet:
48 logger.setLevel(logging.WARNING)
49else:
50 logger.setLevel(logging.INFO)
51
52if len(args) < 1:
53 parser.print_usage()
54 sys.exit(1)
55
56logger.info("Reading Samba3 databases and smb.conf")
57
58libdir = args[0]
59if not os.path.isdir(libdir):
60 print "error: %s is not a directory"
61 sys.exit(1)
62
63if len(args) > 1:
64 smbconf = args[1]
65else:
66 smbconf = os.path.join(libdir, "smb.conf")
67
68samba3 = Samba3(libdir, smbconf)
69
70logger.info("Provisioning")
71
72lp = sambaopts.get_loadparm()
73smbconf = lp.configfile
74creds = credopts.get_credentials(lp)
75
76upgrade_provision(samba3, logger, credentials=creds,
77 session_info=system_session(), smbconf=smbconf,
78 targetdir=opts.targetdir)
Note: See TracBrowser for help on using the repository browser.