From 4c674a24764b2ced7e8a60fcab0337c07c6370eb Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Wed, 30 Apr 2014 00:05:38 +0100 Subject: [PATCH] Use grub2-mkconfig if update-grub isn't present update-grub doesn't exist on fedora so if the legacy grub config file is being used use grub2-mkconfig instead. Also slightly change the sed GRUB_CMDLINE_LINUX regex so that it will match if the command line already contains entries. Change-Id: I21ce382a0023d674a4a2e6afecc9bc678791eac9 --- .../files/nodepool/scripts/restrict_memory.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/openstack_project/files/nodepool/scripts/restrict_memory.sh b/modules/openstack_project/files/nodepool/scripts/restrict_memory.sh index 332e2fcba8..a5fd406aba 100755 --- a/modules/openstack_project/files/nodepool/scripts/restrict_memory.sh +++ b/modules/openstack_project/files/nodepool/scripts/restrict_memory.sh @@ -19,8 +19,13 @@ # cpu resources can be used without the risk of becoming dependent on more # memory. if [ -f /etc/default/grub ] ; then - sudo sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' -e 's/#\?GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="mem=8G"/g' /etc/default/grub - sudo update-grub + sudo sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' -e 's/#\?GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="mem=8G /g' /etc/default/grub + if which update-grub &> /dev/null ; then + sudo update-grub + else + # If update-grub isn't available, use grub2-mkconfig directly + sudo grub2-mkconfig -o /boot/grub2/grub.cfg + fi elif [ -f /boot/grub/grub.conf ] ; then sudo sed -i -e 's/^timeout=[0-9]\+/timeout=0/' -e 's/\(^\s\+kernel.*\)/\1 mem=8G/' /boot/grub/grub.conf fi