summaryrefslogblamecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe/inc/localboot.inc.php
blob: 4d1a56c77d9d9d6ad69b64aaae2c0d846a707f52 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                     
                             
                                                    
        





                                                                          
                                                    
        







                                                            
                                                              
                  

          


                                                     
                                                  
         
                                                                                       
                                  
                                                   
                                            
                                           
                 
                                                                    

                                            
                                                                 
                                         



                                                               
                                                                      




                                                                  
<?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");
	}

}