s4-smbtorture: add test_CreateKey_opts() to RPC-WINREG test.
[Samba/nascimento.git] / swat2 / install / samba3.esp
blob4de942f972a2129c07de86ad388c20f2e2d6ac22
1 <% page_header("columns", "Upgrade", "install"); 
3  /* frontend to Samba3 upgrade.
4         Based on provision.esp
5         (C) Jelmer Vernooij 2005
6         Published under the GNU GPL
7   */
9   include("/scripting/forms.js");
10   libinclude("base.js");
11   libinclude("provision.js");
12   libinclude("upgrade.js");
15 <h1>Import from Samba3</h1>
18 if ((session.authinfo.user_class == "ADMINISTRATOR")
19          || (session.authinfo.user_class == "SYSTEM")) {
21         if (form['submit'] == "Cancel") {
22                 redirect("/");
23         }
25         function confirm_form()
26         {
27                 var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
29                 var subobj = upgrade_provision(samba3);
30                 var f = FormObj("Import from Samba3", 0, 2);
31                 subobj.ADMINPASS = "";
33                 f.add("REALM", "Realm");
34                 f.add("DOMAIN", "Domain Name");
35                 f.add("HOSTNAME", "Hostname");
36                 f.add("ADMINPASS", "Administrator Password", "password");
37                 f.add("CONFIRM", "Confirm Password", "password");
38                 f.add("DOMAINSID", "Domain SID");
39                 f.add("HOSTGUID", "Host GUID");
40                 f.add("HOSTIP", "Host IP");
41                 f.add("DEFAULTSITE", "Default Site");
43                 for (i=0;i<f.element.length;i++) {
44                         f.element[i].value = subobj[f.element[i].name];
45                 }
47                 f.add("SMBCONF", "", "hidden", form['SMBCONF']);
48                 f.add("LIBDIR", "", "hidden", form['LIBDIR']);
50                 f.submit[0] = "Continue";
51                 f.submit[1] = "Cancel";
52                 f.display();    
53         }
55         if (form['submit'] == "Import") {
56                 confirm_form();
57         } else if (form['submit'] == "Continue") {
58                 var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
59                 assert(samba3 != undefined);
60                 var subobj = upgrade_provision(samba3);
61                 for (r in form) {
62                         subobj[r] = form[r];
63                 }
65                 var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
67                 if (!goodpass) {
68                         write("<h3>Passwords don't match.  Please try again.</h3>");
69                         confirm_form();
70                 } else if (subobj.ADMINPASS == "") {
71                         write("<h3>You must choose an administrator password.  Please try again.</h3>");
72                         confirm_form();
73                 } else {
74                         var paths = provision_default_paths(subobj);
75                         if (!provision(subobj, writefln, true, paths, 
76                                        session.authinfo.session_info, session.authinfo.credentials)) {
77                                 writefln("Provision failed!");
78                         } else { 
79                                 var ret = upgrade(subobj,samba3,message,paths,
80                                                   session.authinfo.session_info, session.authinfo.credentials);
81                                 if (ret > 0) {
82                                         writefln("Failed to import %d entries\n", ret);
83                                 } else {
84                                         if (!provision_dns(subobj, writefln, paths,
85                                                            session.authinfo.session_info, session.authinfo.credentials)) {
86                                                 writefln("DNS Provision failed!");
87                                         } else {
88                                                 writefln("Reloading smb.conf\n");
89                                                 var lp = loadparm_init();
90                                                 lp.reload();
91                                                 writefln("Upgrade Complete!");
92                                         }
93                                 }
94                         }
95                 }
96         } else {
97                 var f = FormObj("Import from Samba3", 0, 2);
99                 f.add("SMBCONF", "smb.conf file", "text", "/etc/samba/smb.conf");
100                 f.add("LIBDIR", "Lib directory", "text", "/var/lib/samba");
101                 f.submit[0] = "Import";
102                 f.submit[1] = "Cancel";
104                 write('<p>Warning: This will erase your current configuration!</p>');
105                 f.display();
106         }
107 } else {
108         redirect("/");
112 <% page_footer(); %>