Fix OpenChange server code and access to Samba4 databases.
[OpenChange-git-clone.git] / setup / openchange_provision
blobf617eb2ef12b1f826360a57dd751bd86e36a0e16
1 #!/usr/bin/python
2 # OpenChange provision script
4 # Copyright (C) Jelmer Vernooij <jelmer@openchange.org> 2008
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.
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.
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/>.
20 import optparse
21 import os,sys
23 # To allow running from the source directory
24 sys.path.append("python")
26 from openchange import find_samba_python_path
27 samba_path = find_samba_python_path()
28 if samba_path is not None:
29 sys.path.append(samba_path)
31 import samba
32 import samba.getopt as options
33 from samba.auth import system_session
34 import openchange.provision as openchange
36 parser = optparse.OptionParser("openchange_provision [options]")
38 sambaopts = options.SambaOptions(parser)
39 parser.add_option_group(sambaopts)
41 credopts = options.CredentialsOptions(parser)
42 parser.add_option_group(credopts)
43 parser.add_option("--firstorg", type="string", metavar="FIRSTORG",
44 help="set OpenChange First Organization (otherwise First Organization)")
45 parser.add_option("--firstou", type="string", metavar="FIRSTOU",
46 help="set OpenChange First Organization Unit (otherwise First Organization Unit)")
47 parser.add_option("--openchangedb", action="store_true", help="Initialize OpenChange dispatcher database")
49 opts,args = parser.parse_args()
50 if len(args) != 0:
51 parser.print_usage()
52 sys.exit(1)
54 lp = sambaopts.get_loadparm()
55 creds = credopts.get_credentials(lp)
57 def setup_path(*args):
58 return os.path.join(os.path.dirname(__file__), *args)
60 if not opts.openchangedb:
61 openchange.provision(setup_path, lp, creds, firstorg=opts.firstorg, firstou=opts.firstou)
62 else:
63 openchange.openchangedb_provision(lp, firstorg=opts.firstorg, firstou=opts.firstou)