2 # OpenChange provision script
4 # Copyright (C) Jelmer Vernooij <jelmer@openchange.org> 2008
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/>.
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
)
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()
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
)
63 openchange
.openchangedb_provision(lp
, firstorg
=opts
.firstorg
, firstou
=opts
.firstou
)