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

Use Augeas to manage (remove) Grub0 kernel options.

Augeas knows the grammar for the Grub0 config file, so we don't need
to have complicated regular expressions in our code to deal with all
the corner cases.
parent 256b7cad
Branches
No related tags found
No related merge requests found
# Copyright © 2017 Thomas Bellman, Linköping, Sweden # Copyright © 2017-2018 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information. # Licensed under the GNU LGPL v3+; see the README file for more information.
...@@ -7,18 +7,14 @@ ...@@ -7,18 +7,14 @@
*/ */
define bootloader::grub0::kernel_option($ensure, $value) define bootloader::grub0::kernel_option($ensure, $value)
{ {
$prefix = '^(\s*kernel\s(|.*\s))'
$suffix = '(|\s.*)$'
$qname = regexp_quote($name)
if ($ensure == 'absent') if ($ensure == 'absent')
{ {
regexp_replace_lines { augeas {
"bootloader::grub0::kernel_option::${name}": "bootloader::grub0::kernel_option::${name}":
file => '/boot/grub/grub.conf', incl => '/boot/grub/grub.conf',
pattern => "${prefix}${qname}(=\\S*)?${suffix}", lens => 'Grub.lns',
# \1 is prefix, \4 is suffix context => '/files/boot/grub/grub.conf',
replacement => '\1\4'; changes => "rm title[*]/kernel/${name}";
} }
} }
elsif ($ensure != 'present') elsif ($ensure != 'present')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment