source: branches/samba-3.5.x/source4/setup/upgrade@ 778

Last change on this file since 778 was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 2.6 KB
Line 
1#!/usr/bin/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 getopt
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 import param
29from samba.auth import system_session
30
31parser = optparse.OptionParser("upgrade [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("--setupdir", type="string", metavar="DIR",
38 help="directory with setup files")
39parser.add_option("--realm", type="string", metavar="REALM", help="set realm")
40parser.add_option("--quiet", help="Be quiet")
41parser.add_option("--blank",
42 help="do not add users or groups, just the structure")
43parser.add_option("--targetdir", type="string", metavar="DIR",
44 help="Set target directory")
45
46opts, args = parser.parse_args()
47
48def message(text):
49 """Print a message if quiet is not set."""
50 if opts.quiet:
51 print text
52
53if len(args) < 1:
54 parser.print_usage()
55 sys.exit(1)
56from samba.samba3 import Samba3
57message("Reading Samba3 databases and smb.conf\n")
58libdir = args[0]
59if not os.path.isdir(libdir):
60 print "error: %s is not a directory"
61 sys.exit(1)
62if len(args) > 1:
63 smbconf = args[1]
64else:
65 smbconf = os.path.join(libdir, "smb.conf")
66samba3 = Samba3(libdir, smbconf)
67
68from samba.provision import find_setup_dir
69from samba.upgrade import upgrade_provision
70
71message("Provisioning\n")
72
73setup_dir = opts.setupdir
74if setup_dir is None:
75 setup_dir = find_setup_dir()
76
77lp = sambaopts.get_loadparm()
78smbconf = lp.configfile
79creds = credopts.get_credentials(lp)
80
81upgrade_provision(samba3, setup_dir, message, credentials=creds,
82 session_info=system_session(), smbconf=smbconf,
83 targetdir=opts.targetdir)
Note: See TracBrowser for help on using the repository browser.