2005-07-14 13:51:49 +04:00
#!/bin/sh
2005-08-02 02:10:24 +04:00
exec smbscript "$0" ${1+"$@"}
2005-07-11 13:20:47 +04:00
/*
provision a Samba4 server
Copyright Andrew Tridgell 2005
Released under the GNU GPL v2 or later
*/
2005-08-22 18:32:58 +04:00
options = GetOptions(ARGV,
2005-07-11 13:20:47 +04:00
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_VERSION",
'realm=s',
'domain=s',
'domain-guid=s',
'domain-sid=s',
'host-name=s',
'host-ip=s',
'host-guid=s',
'invocationid=s',
'adminpass=s',
'krbtgtpass=s',
'machinepass=s',
'root=s',
'nobody=s',
'nogroup=s',
'wheel=s',
'users=s',
2005-07-27 04:23:09 +04:00
'quiet',
'blank');
2005-08-22 18:32:58 +04:00
if (options == undefined) {
2005-08-26 15:38:07 +04:00
println("Failed to parse options");
2005-07-11 13:20:47 +04:00
return -1;
}
libinclude("base.js");
2005-07-12 15:46:34 +04:00
libinclude("provision.js");
2005-07-12 06:36:07 +04:00
2005-07-11 13:20:47 +04:00
/*
print a message if quiet is not set
*/
2005-07-12 15:46:34 +04:00
function message()
2005-07-11 13:20:47 +04:00
{
if (options["quiet"] == undefined) {
2005-07-12 15:46:34 +04:00
print(vsprintf(arguments));
2005-07-12 10:02:20 +04:00
}
}
2005-07-11 13:20:47 +04:00
/*
show some help
*/
function ShowHelp()
{
print("
Samba4 provisioning
2005-07-13 09:29:05 +04:00
provision [options]
2005-07-11 13:20:47 +04:00
--realm REALM set realm
--domain DOMAIN set domain
--domain-guid GUID set domainguid (otherwise random)
--domain-sid SID set domainsid (otherwise random)
--host-name HOSTNAME set hostname
--host-ip IPADDRESS set ipaddress
--host-guid GUID set hostguid (otherwise random)
--invocationid GUID set invocationid (otherwise random)
--adminpass PASSWORD choose admin password (otherwise random)
--krbtgtpass PASSWORD choose krbtgt password (otherwise random)
--machinepass PASSWORD choose machine password (otherwise random)
--root USERNAME choose 'root' unix username
--nobody USERNAME choose 'nobody' user
--nogroup GROUPNAME choose 'nogroup' group
--wheel GROUPNAME choose 'wheel' privileged group
--users GROUPNAME choose 'users' group
--quiet Be quiet
2005-07-27 04:23:09 +04:00
--blank do not add users or groups, just the structure
2005-07-11 13:20:47 +04:00
You must provide at least a realm and domain
");
exit(1);
}
2005-07-12 06:36:07 +04:00
if (options['host-name'] == undefined) {
options['host-name'] = hostname();
}
2005-07-11 13:20:47 +04:00
/*
main program
*/
if (options["realm"] == undefined ||
options["domain"] == undefined ||
options["host-name"] == undefined) {
ShowHelp();
}
2005-07-20 14:07:48 +04:00
/* cope with an initially blank smb.conf */
var lp = loadparm_init();
lp.set("realm", options.realm);
lp.set("workgroup", options.domain);
lp.reload();
2005-07-12 15:46:34 +04:00
var subobj = provision_guess();
2005-07-12 01:53:10 +04:00
for (r in options) {
2005-07-12 06:36:07 +04:00
var key = strupper(join("", split("-", r)));
subobj[key] = options[r];
2005-07-11 13:20:47 +04:00
}
2005-07-12 06:36:07 +04:00
2005-07-30 06:02:52 +04:00
var blank = (options["blank"] != undefined);
2005-09-13 03:52:25 +04:00
if (!provision_validate(subobj, message)) {
return -1;
}
2005-07-12 15:46:34 +04:00
message("Provisioning for %s in realm %s\n", subobj.DOMAIN, subobj.REALM);
message("Using administrator password: %s\n", subobj.ADMINPASS);
2005-08-31 06:39:57 +04:00
provision(subobj, message, blank, provision_default_paths(subobj));
2005-07-12 15:46:34 +04:00
message("All OK\n");
2005-07-12 01:53:10 +04:00
return 0;