Skip to content
Snippets Groups Projects
Commit e9ed9c7a authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Definition for managing kernel commandline options.

This adds a definition bootloader::kernel_option for managing kernel
command line options.  The implementation is currently rudimentary,
and only support removing options when Grub 0.x is used; Grub 2.x or
setting options is not yet implemented.
parent e0f40f44
No related branches found
No related tags found
No related merge requests found
# Copyright © 2017 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
/*
* Internal helper for the bootloader::kernel_option definition.
*/
define bootloader::grub0::kernel_option($ensure, $value)
{
$prefix = '^(\s*kernel\s(|.*\s))'
$suffix = '(|\s.*)$'
$qname = regexp_quote($name)
if ($ensure == 'absent')
{
regexp_replace_lines {
"bootloader::grub0::kernel_option::${name}":
file => '/boot/grub/grub.conf',
pattern => "${prefix}${qname}(=\\S*)?${suffix}",
# \1 is prefix, \4 is suffix
replacement => '\1\4';
}
}
elsif ($ensure != 'present')
{
fail("Bootloader::Grub0::Kernel_Option[${title}]: ",
"Bad ensure parameter, ${ensure}")
}
elsif ($value == true or $value == false)
{
# Detecting if the option is already present is not easily done
# using regexps...
fail("Bootloader::Grub0::Kernel_option[${title}]: ",
"Setting a kernel option is not yet implemented.")
}
else
{
# Detecting if the option is already present is not easily done
# using regexps...
fail("Bootloader::Grub0::Kernel_option[${title}]: ",
"Setting a kernel option is not yet implemented.")
}
}
# Copyright © 2017 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
/*
* Set or remove a kernel commandline option.
*
* Which bootloader is in use will be guessed. The heuristics for that
* are not very good.
*
* Parameters:
* - name Kernel commandline option to set or remove.
*
* - ensure One of 'present' or 'absent'.
* Currently only 'absent' is implemented!
*
* - value The value to set the option to. If set to true or false,
* it will be a "bare" option, i.e. something like "single".
* If a string, a valued option will be set, i.e. something
* like "console=ttyS0".
* Since only ensure => absent is implemented, the value
* parameter is currently ignored.
*/
define bootloader::kernel_option($ensure='present', $value=undef)
{
include bootloader::guess
$bootloader = $bootloader::guess::bootloader
case $bootloader
{
'grub0': {
bootloader::grub0::kernel_option {
$title:
name => $name, ensure => $ensure, value => $value;
}
}
default: {
fail("Bootloader::Kernel_option[${title}]: ",
"Unsupported bootloader, ${bootloader}")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment