r12928: This patch improves the interaction between the vampire and provsion code.
[kai/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("HOSTIP", "Host IP");
38         f.add("DEFAULTSITE", "Default Site");
39
40         for (i=0;i<f.element.length;i++) {
41                 f.element[i].value = subobj[f.element[i].name];
42         }
43
44         f.add("SMBCONF", "", "hidden", form['SMBCONF']);
45         f.add("LIBDIR", "", "hidden", form['LIBDIR']);
46
47         f.submit[0] = "Continue";
48         f.submit[1] = "Cancel";
49         f.display();    
50 }
51
52 if (form['submit'] == "Import") {
53         confirm_form();
54 } else if (form['submit'] == "Continue") {
55         var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
56         assert(samba3 != undefined);
57         var subobj = upgrade_provision(samba3);
58         for (r in form) {
59                 subobj[r] = form[r];
60         }
61
62         var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
63
64         if (!goodpass) {
65                 write("<h3>Passwords don't match.  Please try again.</h3>");
66                 confirm_form();
67         } else if (subobj.ADMINPASS == "") {
68                 write("<h3>You must choose an administrator password.  Please try again.</h3>");
69                 confirm_form();
70         } else {
71                 var paths = provision_default_paths(subobj);
72
73                 provision(subobj, writefln, true, paths);
74                 upgrade(subobj, samba3, writefln, paths);
75
76                 writefln("Reloading smb.conf\n");
77                 var lp = loadparm_init();
78                 lp.reload();
79         }
80 } else {
81         var f = FormObj("Import from Samba3", 0, 2);
82
83         f.add("SMBCONF", "smb.conf file", "text", "/etc/samba/smb.conf");
84         f.add("LIBDIR", "Lib directory", "text", "/var/lib/samba");
85         f.submit[0] = "Import";
86         f.submit[1] = "Cancel";
87
88         write('<p>Warning: This will erase your current configuration!</p>');
89         f.display();
90 }
91 %>
92
93 <% page_footer(); %>