0b0a83fba6b0eeea577ff360256e0a4daf9138de
[jra/samba/.git] / swat / install / provision.esp
1 <% page_header("columns", "Provisioning", "install"); 
2
3   include("/scripting/forms.js");
4   libinclude("base.js");
5   libinclude("provision.js");
6 %>
7
8 <h1>Samba4 provisioning</h1>
9
10 <%
11 var f = FormObj("Provisioning", 0, 2);
12 var i;
13 var lp = loadparm_init();
14
15 if ((session.authinfo.user_class == "ADMINISTRATOR")
16          || (session.authinfo.user_class == "SYSTEM")) {
17
18         if (lp.get("realm") == "") {
19                 lp.set("realm", lp.get("workgroup") + ".example.com");
20         }
21
22         var subobj = provision_guess();
23         /* Don't supply default password for web interface */
24         subobj.ADMINPASS = "";
25
26         f.add("REALM", "DNS Domain Name");
27         f.add("DOMAIN", "NetBIOS Domain Name");
28         f.add("HOSTNAME", "Hostname");
29         f.add("ADMINPASS", "Administrator Password", "password");
30         f.add("CONFIRM", "Confirm Password", "password");
31         f.add("DOMAINSID", "Domain SID");
32         f.add("HOSTIP", "Host IP");
33         f.add("DEFAULTSITE", "Default Site");
34         f.submit[0] = "Provision";
35         f.submit[1] = "Cancel";
36
37         if (form['submit'] == "Cancel") {
38                 redirect("/");
39         }
40
41         if (form['submit'] == "Provision") {
42                 for (r in form) {
43                         subobj[r] = form[r];
44                 }
45         }
46
47         for (i=0;i<f.element.length;i++) {
48                 f.element[i].value = subobj[f.element[i].name];
49         }
50
51         if (form['submit'] == "Provision") {
52         
53                 /* overcome an initially blank smb.conf */
54                 lp.set("realm", subobj.REALM);
55                 lp.set("workgroup", subobj.DOMAIN);
56                 lp.reload();
57                 var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
58
59                 if (!goodpass) {
60                         write("<h3>Passwords don't match.  Please try again.</h3>");
61                         f.display();
62                 } else if (subobj.ADMINPASS == "") {
63                         write("<h3>You must choose an administrator password.  Please try again.</h3>");
64                         f.display();
65                 } else if (!provision_validate(subobj, writefln)) {
66                         f.display();
67                 } else {
68                         var paths = provision_default_paths(subobj);
69                         if (!provision(subobj, writefln, false, paths, 
70                                        session.authinfo.session_info, session.authinfo.credentials, false)) {
71                                 writefln("Provision failed!");
72                         } else if (!provision_dns(subobj, writefln, paths,
73                                                   session.authinfo.session_info, session.authinfo.credentials)) {
74                                 writefln("DNS Provision failed!");
75                         } else {
76                                 writefln("Provision Complete!");
77                         }
78                 }
79         } else {
80                 f.display();
81         }
82 } else {
83         redirect("/");
84 }
85
86 %>
87
88
89 <% page_footer(); %>