2005-08-28 22:17:07 +00:00
<% page_header("columns", "Upgrade", "install");
2005-08-29 18:52:24 +00:00
/* frontend to Samba3 upgrade.
Based on provision.esp
(C) Jelmer Vernooij 2005
Published under the GNU GPL
*/
2005-08-28 22:17:07 +00:00
include("/scripting/forms.js");
libinclude("base.js");
libinclude("provision.js");
2005-08-29 20:18:51 +00:00
libinclude("upgrade.js");
2005-08-28 22:17:07 +00:00
%>
<h1>Import from Samba3</h1>
<%
if (form['submit'] == "Cancel") {
redirect("/");
}
2005-08-31 15:47:10 +00:00
function confirm_form()
{
2005-08-29 20:18:51 +00:00
var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
2005-08-29 12:31:32 +00:00
2005-08-29 18:52:24 +00:00
var subobj = upgrade_provision(samba3);
2005-08-29 12:31:32 +00:00
var f = FormObj("Import from Samba3", 0, 2);
2005-08-31 15:47:10 +00:00
subobj.ADMINPASS = "";
2005-08-29 18:52:24 +00:00
f.add("REALM", "Realm");
f.add("DOMAIN", "Domain Name");
f.add("HOSTNAME", "Hostname");
f.add("ADMINPASS", "Administrator Password", "password");
f.add("CONFIRM", "Confirm Password", "password");
f.add("DOMAINSID", "Domain SID");
f.add("HOSTGUID", "Host GUID");
f.add("HOSTIP", "Host IP");
f.add("DEFAULTSITE", "Default Site");
for (i=0;i<f.element.length;i++) {
f.element[i].value = subobj[f.element[i].name];
}
2005-08-29 20:18:51 +00:00
f.add("SMBCONF", "", "hidden", form['SMBCONF']);
f.add("LIBDIR", "", "hidden", form['LIBDIR']);
2005-08-29 12:31:32 +00:00
f.submit[0] = "Continue";
f.submit[1] = "Cancel";
f.display();
2005-08-31 15:47:10 +00:00
}
if (form['submit'] == "Import") {
confirm_form();
2005-08-29 12:31:32 +00:00
} else if (form['submit'] == "Continue") {
2005-08-29 20:18:51 +00:00
var samba3 = samba3_read(form['LIBDIR'], form['SMBCONF']);
assert(samba3 != undefined);
var subobj = upgrade_provision(samba3);
2005-08-29 18:52:24 +00:00
for (r in form) {
subobj[r] = form[r];
}
2005-08-31 02:39:57 +00:00
2005-08-31 15:47:10 +00:00
var goodpass = (subobj.CONFIRM == subobj.ADMINPASS);
2005-08-31 02:39:57 +00:00
2005-08-31 15:47:10 +00:00
if (!goodpass) {
write("<h3>Passwords don't match. Please try again.</h3>");
confirm_form();
} else if (subobj.ADMINPASS == "") {
write("<h3>You must choose an administrator password. Please try again.</h3>");
confirm_form();
} else {
var paths = provision_default_paths(subobj);
2006-01-15 09:03:28 +00:00
if (!provision(subobj, writefln, true, paths,
session.authinfo.session_info, session.authinfo.credentials)) {
writefln("Provision failed!");
} else {
var ret = upgrade(subobj,samba3,message,paths,
session.authinfo.session_info, session.authinfo.credentials);
if (ret > 0) {
writefln("Failed to import %d entries\n", ret);
} else {
if (!provision_dns(subobj, writefln, paths,
session.authinfo.session_info, session.authinfo.credentials)) {
writefln("DNS Provision failed!");
} else {
writefln("Reloading smb.conf\n");
var lp = loadparm_init();
lp.reload();
writefln("Upgrade Complete!");
}
}
}
2005-08-31 15:47:10 +00:00
}
2005-08-29 12:31:32 +00:00
} else {
var f = FormObj("Import from Samba3", 0, 2);
2005-08-28 22:17:07 +00:00
2005-08-29 20:18:51 +00:00
f.add("SMBCONF", "smb.conf file", "text", "/etc/samba/smb.conf");
f.add("LIBDIR", "Lib directory", "text", "/var/lib/samba");
2005-08-29 12:31:32 +00:00
f.submit[0] = "Import";
f.submit[1] = "Cancel";
2005-08-29 20:18:51 +00:00
write('<p>Warning: This will erase your current configuration!</p>');
2005-08-28 22:17:07 +00:00
f.display();
}
%>
<% page_footer(); %>