From 193b765f07543b4824950fe08d337211c2ef8a1c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 17 Oct 2019 14:41:03 +0200 Subject: [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... --- .../serversetup-bwlp-ipxe/inc/ipxe.inc.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php') 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; + } + } -- cgit v1.2.3-55-g7522