mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
503d15e8df
- removed workaround for olcSyncprovConfig - creation (works perfect now with 2.4.15, release was today) - added 1 message-helpline, which is displayed when running provision-backend with olc and/or mmr setup - corrected 1 wrong slapcommand-helpline - slapd.conf is removed now in case of olc-setup - added 1 copyright-line to provision.py and provision-backend Signed-off-by: Andrew Bartlett <abartlet@samba.org>
115 lines
4.4 KiB
Python
Executable File
115 lines
4.4 KiB
Python
Executable File
#!/usr/bin/python
|
|
#
|
|
# Unix SMB/CIFS implementation.
|
|
# provision a Samba4 server
|
|
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
|
|
# Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
|
|
# Copyright (C) Oliver Liebel <oliver@itc.li> 2008-2009
|
|
#
|
|
# Based on the original in EJS:
|
|
# Copyright (C) Andrew Tridgell 2005
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import os, sys
|
|
|
|
sys.path.insert(0, "bin/python")
|
|
|
|
import getopt
|
|
import optparse
|
|
|
|
import samba
|
|
from samba import param
|
|
|
|
from samba.auth import system_session
|
|
import samba.getopt as options
|
|
from samba.provision import provision_backend, find_setup_dir
|
|
|
|
parser = optparse.OptionParser("provision [options]")
|
|
sambaopts = options.SambaOptions(parser)
|
|
parser.add_option_group(sambaopts)
|
|
parser.add_option_group(options.VersionOptions(parser))
|
|
credopts = options.CredentialsOptions(parser)
|
|
parser.add_option_group(credopts)
|
|
parser.add_option("--setupdir", type="string", metavar="DIR",
|
|
help="directory with setup files")
|
|
parser.add_option("--realm", type="string", metavar="REALM", help="set realm")
|
|
parser.add_option("--domain", type="string", metavar="DOMAIN",
|
|
help="set domain")
|
|
parser.add_option("--host-name", type="string", metavar="HOSTNAME",
|
|
help="set hostname")
|
|
parser.add_option("--ldap-admin-pass", type="string", metavar="PASSWORD",
|
|
help="choose LDAP admin password (otherwise random)")
|
|
parser.add_option("--root", type="string", metavar="USERNAME",
|
|
help="choose 'root' unix username")
|
|
parser.add_option("--quiet", help="Be quiet", action="store_true")
|
|
parser.add_option("--ldap-backend-type", type="choice", metavar="LDAP-BACKEND-TYPE",
|
|
help="LDB mapping module to use for the LDAP backend",
|
|
choices=["fedora-ds", "openldap"])
|
|
parser.add_option("--ldap-backend-port", type="int", metavar="PORT",
|
|
help="TCP Port LDAP server should listen to (default ldapi only)")
|
|
parser.add_option("--server-role", type="choice", metavar="ROLE",
|
|
choices=["domain controller", "dc", "member server", "member", "standalone"],
|
|
help="Set server role to provision for (default standalone)")
|
|
parser.add_option("--targetdir", type="string", metavar="DIR",
|
|
help="Set target directory")
|
|
parser.add_option("--ol-mmr-urls", type="string", metavar="LDAPSERVER",
|
|
help="List of LDAP-URLS [ ldap://<FQHN>:<PORT>/ (where <PORT> has to be different from 389!) ] separated with whitespaces for use with OpenLDAP-MMR (Multi-Master-Replication)")
|
|
parser.add_option("--ol-olc", type="choice", metavar="OPENLDAP-OLC",
|
|
help="To setup OpenLDAP-Backend with Online-Configuration [slapd.d] choose 'yes'. Note: Only OpenLDAP-Versions greater or equal 2.4.15 should be used!",
|
|
choices=["yes", "no"])
|
|
parser.add_option("--ol-slaptest", type="string", metavar="SLAPTEST-PATH",
|
|
help="Path to slaptest-binary [e.g.:'/usr/local/sbin']. Only for use with --ol-olc='yes'")
|
|
|
|
opts = parser.parse_args()[0]
|
|
|
|
def message(text):
|
|
"""print a message if quiet is not set."""
|
|
if not opts.quiet:
|
|
print text
|
|
|
|
if opts.realm is None or opts.domain is None:
|
|
if opts.realm is None:
|
|
print >>sys.stderr, "No realm set"
|
|
if opts.domain is None:
|
|
print >>sys.stderr, "No domain set"
|
|
parser.print_usage()
|
|
sys.exit(1)
|
|
|
|
smbconf = sambaopts.get_loadparm().configfile
|
|
|
|
if opts.server_role == "dc":
|
|
server_role = "domain controller"
|
|
elif opts.server_role == "member":
|
|
server_role = "member server"
|
|
else:
|
|
server_role = opts.server_role
|
|
|
|
setup_dir = opts.setupdir
|
|
if setup_dir is None:
|
|
setup_dir = find_setup_dir()
|
|
|
|
provision_backend(setup_dir=setup_dir, message=message, smbconf=smbconf, targetdir=opts.targetdir,
|
|
realm=opts.realm, domain=opts.domain,
|
|
hostname=opts.host_name,
|
|
adminpass=opts.ldap_admin_pass,
|
|
root=opts.root, serverrole=server_role,
|
|
ldap_backend_type=opts.ldap_backend_type,
|
|
ldap_backend_port=opts.ldap_backend_port,
|
|
ol_mmr_urls=opts.ol_mmr_urls,
|
|
ol_olc=opts.ol_olc,
|
|
ol_slaptest=opts.ol_slaptest)
|
|
|