summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-02-26 23:15:48 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-02-27 00:52:46 +0100
commit687e065036d0d39099a6ec909860c07144b8aa51 (patch)
treee872b0c9ff0279267501df0e7b2f6e66792036ed /source4/scripting/python
parentbb4de6df6ef2ff155e2bdc10794c232a288b0a9b (diff)
downloadsamba-687e065036d0d39099a6ec909860c07144b8aa51.tar.gz
samba-687e065036d0d39099a6ec909860c07144b8aa51.tar.bz2
samba-687e065036d0d39099a6ec909860c07144b8aa51.zip
provision: Write configuration without help of templates.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Mon Feb 27 00:52:46 CET 2012 on sn-devel-104
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/provision/__init__.py72
1 files changed, 34 insertions, 38 deletions
diff --git a/source4/scripting/python/samba/provision/__init__.py b/source4/scripting/python/samba/provision/__init__.py
index fa686c3137..48dd8673c7 100644
--- a/source4/scripting/python/samba/provision/__init__.py
+++ b/source4/scripting/python/samba/provision/__init__.py
@@ -601,14 +601,6 @@ def make_smbconf(smbconf, hostname, domain, realm, targetdir,
if serverrole is None:
serverrole = "standalone"
- try:
- smbconfsuffix = {
- "domain controller": "dc",
- "member server": "member",
- "standalone": "standalone"}[serverrole]
- except KeyError:
- raise ValueError("server role %r invalid" % serverrole)
-
if sid_generator is None:
sid_generator = "internal"
@@ -618,6 +610,14 @@ def make_smbconf(smbconf, hostname, domain, realm, targetdir,
assert realm is not None
realm = realm.upper()
+ global_settings = {
+ "passdb backend": "samba4",
+ "netbios name": netbiosname,
+ "workgroup": domain,
+ "realm": realm,
+ "server role": serverrole,
+ }
+
if lp is None:
lp = samba.param.LoadParm()
#Load non-existant file
@@ -631,43 +631,39 @@ def make_smbconf(smbconf, hostname, domain, realm, targetdir,
lp.set("posix:eadb", os.path.abspath(os.path.join(privdir, "eadb.tdb")))
if server_services is not None:
- server_services_line = "server services = " + " ".join(server_services)
- else:
- server_services_line = ""
+ global_settings["server services"] = " ".join(server_services)
if targetdir is not None:
- privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
- lockdir_line = "lock dir = " + os.path.abspath(targetdir)
- statedir_line = "state directory = " + os.path.abspath(targetdir)
- cachedir_line = "cache directory = " + os.path.abspath(targetdir)
+ global_settings["private dir"] = os.path.abspath(os.path.join(targetdir, "private"))
+ global_settings["lock dir"] = os.path.abspath(targetdir)
+ global_settings["state directory"] = os.path.abspath(targetdir)
+ global_settings["cache directory"] = os.path.abspath(targetdir)
lp.set("lock dir", os.path.abspath(targetdir))
lp.set("state directory", os.path.abspath(targetdir))
lp.set("cache directory", os.path.abspath(targetdir))
- else:
- privatedir_line = ""
- lockdir_line = ""
- statedir_line = ""
- cachedir_line = ""
-
- sysvol = os.path.join(lp.get("state directory"), "sysvol")
- netlogon = os.path.join(sysvol, realm.lower(), "scripts")
-
- setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
- smbconf, {
- "NETBIOS_NAME": netbiosname,
- "DOMAIN": domain,
- "REALM": realm,
- "SERVERROLE": serverrole,
- "NETLOGONPATH": netlogon,
- "SYSVOLPATH": sysvol,
- "PRIVATEDIR_LINE": privatedir_line,
- "LOCKDIR_LINE": lockdir_line,
- "STATEDIR_LINE": statedir_line,
- "CACHEDIR_LINE": cachedir_line,
- "SERVER_SERVICES_LINE": server_services_line
- })
+ shares = {}
+ if serverrole == "domain controller":
+ shares["sysvol"] = os.path.join(global_settings["state directory"],
+ "sysvol")
+ shares["netlogon"] = os.path.join(shares["sysvol"], realm.lower(),
+ "scripts")
+
+ f = open(smbconf, 'w')
+ try:
+ f.write("[globals]\n")
+ for key, val in global_settings.iteritems():
+ f.write("\t%s = %s\n" % (key, val))
+ f.write("\n")
+
+ for name, path in shares.iteritems():
+ f.write("[%s]\n" % name)
+ f.write("\tpath = %s\n" % path)
+ f.write("\tread only = no\n")
+ f.write("\n")
+ finally:
+ f.close()
# reload the smb.conf
lp.load(smbconf)