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
|
<?php
class Localboot
{
const PROPERTY_KEY = 'serversetup.localboot';
const BOOT_METHODS = [
'PCBIOS' => [
'EXIT' => 'set slx_exit 1 ||
exit 1',
'COMBOOT' => 'set netX/209:string localboot.cfg ||
set netX/210:string http://${serverip}/tftp/sl-bios/ ||
chain -ar /tftp/sl-bios/lpxelinux.0',
'SANBOOT' => 'sanboot --no-describe',
],
'EFI' => [
'EXIT' => 'set slx_exit 1 ||
exit 1',
'SANBOOT' => 'imgfree ||
console ||
set filename \EFI\Boot\bootx64.efi ||
set i:int32 0 ||
:blubber
sanboot --no-describe --drive ${i} --filename ${filename} ||
inc i
iseq ${i} 10 || goto blubber',
'GRUB' => 'chain /tftp/grub-boot.img',
],
];
/**
* @return array{PCBIOS: string, EFI: string}
*/
public static function getDefault(): array
{
$ret = explode(',', Property::get(self::PROPERTY_KEY, 'SANBOOT,GRUB'));
if (empty($ret)) {
$ret = ['SANBOOT', 'GRUB'];
} elseif (count($ret) < 2) {
$ret[] = 'SANBOOT';
}
if (!isset(self::BOOT_METHODS['PCBIOS'][$ret[0]])) {
$ret[0] = 'SANBOOT';
}
if (!isset(self::BOOT_METHODS['EFI'][$ret[1]])) {
$ret[1] = 'GRUB';
}
return ['PCBIOS' => $ret[0], 'EFI' => $ret[1]];
}
public static function setDefault(string $pcbios, string $efi)
{
Property::set(self::PROPERTY_KEY, "$pcbios,$efi");
}
}
|