summaryrefslogtreecommitdiff
blob: b8ee33ed2d736d669cae32141f71398cb2f5a538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php

include('webgliIP.php');
include('webgliCF.php');
include('webgliUtility.php');

include('Smarty.class.php');
$smarty = new Smarty;

$smarty->template_dir = './templates';
$smarty->compile_dir = './templates_c';
$smarty->cache_dir = './cache';
$smarty->config_dir = './configs';

$ip = new InstallProfile();
$ip->parse('test.xml');
$cf = new ClientConfiguration();
$cf->parse('testcc.xml');

$error_msg = "";

if ($_POST['setbootloader']) {
	if ($_POST['bootloader']) {
		$ip->set("bootloader_pkg",$_POST['bootloader']); 
		$error_msg .= "ERROR: Could not set the bootloader pkg!";
	}
	if ($_POST['bootmbr']) {
		$ip->set("bootloader_mbr",True);
		$error_msg .= "ERROR: Could not set the bootloader MBR flag to TRUE";
		if ($_POST['boot_drive_choice']) {
			$ip->set("boot_device",$_POST['boot_drive_choice']);
			$error_msg .= "ERROR! Could not set the boot device! ".$_POST['boot_drive_choice'];
		}
	}
	else {
		$ip->set("bootloader_mbr",False);
		$error_msg .= "ERROR: Could not set the bootloader MBR flag to FALSE.";
	}
	if ($_POST['bootargs']) {
		$ip->set("bootloader_kernel_args",$_POST['bootargs']);
		$error_msg .= "ERROR: Could not set the bootloader kernel arguments!";
	}
	
	if (!$error_msg) {
		$error_msg = "Values saved successfully";
	}
}
$arch = $cf->get("architecture_template");

$boot_device = $ip->get("boot_device");
	#Bootloader code yanked from the x86ArchTemplate
	$devices = $ip->get("partition_tables");
	$foundboot = False;
	$drives = array_keys($devices);
	sort($drives);
	foreach ($drives as $drive) {
		$partlist = $devices[$drive];
		sort($partlist);
		foreach( $partlist as $part) {
			if ($part["mountpoint"] == "/boot") {
				print "found! <br>";
				$boot_device = $drive;
				$foundboot = True;
			}
			if ( ($part["mountpoint"] == "/") and (!$foundboot)) {
				$boot_device = $drive;
				print "set! $boot_device<br>";
			}
		}
	}
}
print "Boot device: $boot_device <br>";
print substr($boot_device,-1);
/*
bootloader = shared_info.install_profile.get_boot_loader_pkg()
$arch_loaders = array('x86': [
		("grub",(u"GRand Unified Bootloader, newer, RECOMMENDED")),
		("lilo",(u"LInux LOader, older, traditional.(detects windows partitions)"))],
	'amd64': [
		("grub",(u"GRand Unified Bootloader, newer, RECOMMENDED"))]} #FIXME ADD OTHER ARCHS
boot_loaders = arch_loaders[arch]
boot_loaders.append(("none", (u"Do not install a bootloader.	(System may be unbootable!)")))
bootargs = shared_info.install_profile.get_bootloader_kernel_args()
*/
  $bootloaders = array();
  array_push($bootloaders, array("grub", "GRand Unified Bootloader, newer, RECOMMENDED") );
  array_push($bootloaders, array("lilo", "LInux LOader, older, traditional.(detects windows partitions)") );

  $smarty->assign('boot_device', $boot_device);
  $smarty->assign('bootargs', $bootargs);
  $smarty->assign('bootloaders', $bootloaders);
  $smarty->assign('advanced', True); #FIXME
	
	$smarty->display('bootloader.tpl');
?>