summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-12-11 18:51:28 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-12-11 18:51:28 +0100
commit52571a0333d50c58675e858774c6d5eb68a48658 (patch)
tree0c28fa71c1d8e369c423974e49687b23998fcf6f /source4
parent792f769e969da156bbc6330118e200f2eae19d7c (diff)
downloadsamba-52571a0333d50c58675e858774c6d5eb68a48658.tar.gz
samba-52571a0333d50c58675e858774c6d5eb68a48658.tar.bz2
samba-52571a0333d50c58675e858774c6d5eb68a48658.zip
Add interactive flag to setup/provision (also the default when no arguments are given).
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/setup/provision29
1 files changed, 27 insertions, 2 deletions
diff --git a/source4/setup/provision b/source4/setup/provision
index 7bd61fc1d8..882a92ad48 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -24,7 +24,8 @@
import getopt
import optparse
-import os, sys
+import os
+import sys
# Find right directory when running from source tree
sys.path.insert(0, "bin/python")
@@ -46,6 +47,7 @@ parser.add_option_group(sambaopts)
parser.add_option_group(options.VersionOptions(parser))
credopts = options.CredentialsOptions(parser)
parser.add_option_group(credopts)
+parser.add_option("--interactive", help="Ask for names")
parser.add_option("--setupdir", type="string", metavar="DIR",
help="directory with setup files")
parser.add_option("--realm", type="string", metavar="REALM", help="set realm")
@@ -108,7 +110,10 @@ def message(text):
if not opts.quiet:
print text
-if opts.realm is None or opts.domain is None:
+if len(sys.argv) == 1:
+ opts.interactive = True
+
+if not opts.interactive and (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:
@@ -116,6 +121,26 @@ if opts.realm is None or opts.domain is None:
parser.print_usage()
sys.exit(1)
+if opts.interactive:
+ from getpass import getpass
+ import readline
+ import socket
+ def ask(prompt, default=None):
+ if default is not None:
+ print "%s [%s]: " % (prompt,default),
+ else:
+ print "%s: " % (prompt,),
+ return sys.stdin.readline().rstrip("\n") or default
+ opts.realm = ask("Realm", socket.gethostname().split(".", 1)[1])
+ opts.domain = ask("Domain", opts.realm)
+ opts.server_role = ask("Server Role (dc, member, standalone)", "dc")
+ for i in range(3):
+ opts.adminpass = getpass("Administrator password: ")
+ if not opts.adminpass:
+ print >>sys.stderr, "Invalid administrator password."
+ else:
+ break
+
lp = sambaopts.get_loadparm()
smbconf = lp.configfile()