r9831: Check whether the two admin passwords entered were equal.
[jra/samba/.git] / swat / install / samba3.esp
1 <% page_header("columns", "Upgrade", "install"); 
2
3  /* frontend to Samba3 upgrade.
4         Based on provision.esp
5         (C) Jelmer Vernooij 2005
6         Published under the GNU GPL
7   */
8
9   include("/scripting/forms.js");
10   libinclude("base.js");
11   libinclude("provision.js");
12   libinclude("upgrade.js");
13 %>
14
15 <h1>Import from Samba3</h1>
16
17 <%
18 if (form['submit'] == "Cancel") {
19         redirect("/");
20 }
21
22 function confirm_form()
23 {
24         var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
25
26         var subobj = upgrade_provision(samba3);
27         var f = FormObj("Import from Samba3", 0, 2);
28         subobj.ADMINPASS = "";
29
30         f.add("REALM", "Realm");
31         f.add("DOMAIN", "Domain Name");
32         f.add("HOSTNAME", "Hostname");
33         f.add("ADMINPASS", "Administrator Password", "password");
34         f.add("CONFIRM", "Confirm Password", "password");
35         f.add("DOMAINSID", "Domain SID");
36         f.add("HOSTGUID", "Host GUID");
37         f.add("BASEDN", "Base DN");
38         f.add("HOSTIP", "Host IP");
39         f.add("DEFAULTSITE", "Default Site");
40
41         for (i=0;i<f.element.length;i++) {
42                 f.element[i].value = subobj[f.element[i].name];
43         }
44
45         f.add("SMBCONF", "", "hidden", form['SMBCONF']);
46         f.add("LIBDIR", "", "hidden", form['LIBDIR']);
47
48         f.submit[0] = "Continue";
49         f.submit[1] = "Cancel";
50         f.display();    
51 }
52
53 if (form['submit'] == "Import") {
54         confirm_form();
55 } else if (form['submit'] == "Continue") {
56         var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
57         assert(samba3 != undefined);
58         var subobj = upgrade_provision(samba3);
59         for (r in form) {
60                 subobj[r] = form[r];
61         }
62
63         var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
64
65         if (!goodpass) {
66                 write("<h3>Passwords don't match.  Please try again.</h3>");
67                 confirm_form();
68         } else if (subobj.ADMINPASS == "") {
69                 write("<h3>You must choose an administrator password.  Please try again.</h3>");
70                 confirm_form();
71         } else {
72                 var paths = provision_default_paths(subobj);
73
74                 provision(subobj, writefln, true, paths);
75                 upgrade(subobj, samba3, writefln, paths);
76
77                 writefln("Reloading smb.conf\n");
78                 var lp = loadparm_init();
79                 lp.reload();
80         }
81 } else {
82         var f = FormObj("Import from Samba3", 0, 2);
83
84         f.add("SMBCONF", "smb.conf file", "text", "/etc/samba/smb.conf");
85         f.add("LIBDIR", "Lib directory", "text", "/var/lib/samba");
86         f.submit[0] = "Import";
87         f.submit[1] = "Cancel";
88
89         write('<p>Warning: This will erase your current configuration!</p>');
90         f.display();
91 }
92 %>
93
94 <% page_footer(); %>