r12928: This patch improves the interaction between the vampire and provsion code.
[kai/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 (lp.get("realm") == "") {
16         lp.set("realm", lp.get("workgroup") + ".example.com");
17 }
18
19
20 var subobj = provision_guess();
21 /* Don't supply default password for web interface */
22 subobj.ADMINPASS = "";
23
24 f.add("REALM", "DNS Domain Name");
25 f.add("DOMAIN", "NetBIOS Domain Name");
26 f.add("HOSTNAME", "Hostname");
27 f.add("ADMINPASS", "Administrator Password", "password");
28 f.add("CONFIRM", "Confirm Password", "password");
29 f.add("DOMAINSID", "Domain SID");
30 f.add("HOSTIP", "Host IP");
31 f.add("DEFAULTSITE", "Default Site");
32 f.submit[0] = "Provision";
33 f.submit[1] = "Cancel";
34
35 if (form['submit'] == "Cancel") {
36         redirect("/");
37 }
38
39 if (form['submit'] == "Provision") {
40         for (r in form) {
41                 subobj[r] = form[r];
42         }
43 }
44
45 for (i=0;i<f.element.length;i++) {
46         f.element[i].value = subobj[f.element[i].name];
47 }
48
49 if (form['submit'] == "Provision") {
50         lp.set("realm", subobj.REALM);
51         var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
52
53         if (!goodpass) {
54                 write("<h3>Passwords don't match.  Please try again.</h3>");
55                 f.display();
56         } else if (subobj.ADMINPASS == "") {
57                 write("<h3>You must choose an administrator password.  Please try again.</h3>");
58                 f.display();
59         } else if (!provision_validate(subobj, writefln)) {
60                 f.display();
61         } else {
62                 var paths = provision_default_paths(subobj);
63                 if (!provision(subobj, writefln, false, paths, 
64                                session.authinfo.session_info, session.authinfo.credentials)) {
65                         writefln("Provision failed!");
66                 } else if (!provision_dns(subobj, writefln, paths,
67                                           session.authinfo.session_info, session.authinfo.credentials)) {
68                         writefln("DNS Provision failed!");
69                 } else {
70                         writefln("Provision Complete!");
71                 }
72         }
73 } else {
74         f.display();
75 }
76 %>
77
78
79 <% page_footer(); %>