diff options
author | Simon Rettberg | 2019-10-17 14:41:03 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-10-17 14:41:03 +0200 |
commit | 193b765f07543b4824950fe08d337211c2ef8a1c (patch) | |
tree | 4cb54d445e53df797bbf69297c8d360068f94fb7 /modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php | |
parent | [serversetup-bwlp-ipxe/minilinux] Implement minilinux hook for ipxe (diff) | |
download | slx-admin-193b765f07543b4824950fe08d337211c2ef8a1c.tar.gz slx-admin-193b765f07543b4824950fe08d337211c2ef8a1c.tar.xz slx-admin-193b765f07543b4824950fe08d337211c2ef8a1c.zip |
[serversetup-bwlp-ipxe/minilinux] Further improvements
* Distinction between BIOS and EFI for ipxe hook in minilinux
* Debug KCL modifier customizable by update meta data
* Bugfixes, minor refactoring...
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php')
-rw-r--r-- | modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php index 6caecc65..4c2a7678 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php @@ -527,4 +527,30 @@ boot -a -r /boot/default/kernel initrd=initramfs-stage31 ${slxextra} slxbase=boo return md5(md5($plainpass) . '-' . $salt); } + /** + * Modify a kernel command line. Add or remove items to a given command line. The $modifier + * string is a list of space separated arguments. If the argument starts with a '-', all + * according occurrences of the given option will be removed from the command line. It is assumed + * that options are either of format "option" or "option=value", so a modifier of "-option" will + * remove any occurrence of either "option" or "option=something". If the argument starts with a + * '+', it will be added to the command line after removing the '+'. If the argument starts with any + * other character, it will also be added to the command line. + * @param string $cmdLine command line to modify + * @param string $modifier modification string of space separated arguments + * @return string the modified command line + */ + public static function modifyCommandLine($cmdLine, $modifier) + { + $items = preg_split('/\s+/', $modifier, -1, PREG_SPLIT_NO_EMPTY); + foreach ($items as $item) { + if ($item{0} === '-') { + $item = preg_quote(substr($item, 1), '/'); + $cmdLine = preg_replace('/(^|\s)' . $item . '(=\S*)?($|\s)/', ' ', $cmdLine); + } else { + $cmdLine .= ' ' . $item; + } + } + return $cmdLine; + } + } |