Skip to content

Instantly share code, notes, and snippets.

@fourdollars
Created May 6, 2015 09:01
Show Gist options
  • Save fourdollars/07f6fcf51a5e98b09f89 to your computer and use it in GitHub Desktop.
Save fourdollars/07f6fcf51a5e98b09f89 to your computer and use it in GitHub Desktop.
#!/bin/sh
strip_spaces () {
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/ \+/ /g;s/^ *//g;s/ *$//g")
}
remove_parameters () {
for i in "$@"; do
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/$i//g")
done
strip_spaces
}
add_parameters () {
for i in "$@"; do
if ! echo "$GRUB_CMDLINE_LINUX_DEFAULT" | grep "$i" >/dev/null 2>&1; then
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT $i"
fi
done
}
GRUB_CMDLINE_LINUX_DEFAULT="quiet abc def splash"
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\""
add_parameters quiet splash "acpi_osi=\"Windows 2013\"" zswap.enabled=1
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\""
remove_parameters abc def
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\""
remove_parameters "acpi_osi=\"Windows 2013\"" zswap.enabled=1
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment