I need to be able to update the grub config to remove the recovery mode boot option, programmatically. I got the initial info for how to do this (manually) from this question/answer:
How to disable recovery mode/single user mode?
So I wrote a simple script, which is packaged up with a replacement grub file. The script simple does:
# Move the new grub file contents into place
cat /path/to/replacement/grub > /etc/default/grub
# Update grub with the new settings
update-grub
In this script the "/path/to/replacement/grub" has these contents: http://paste.ubuntu.com/7328274/, and replaces the standard file http://paste.ubuntu.com/7328269/ that's in the system. The system is Ubuntu 12.04, and the script above is run as sudo.
The problem is that most of the time it works, but some of the time it completely nerfs grub, and when the system is rebooted, it lands at the grub command line, rather than booting normally. From the grub command line, I can load the kernel, boot linux, and then when at the bash command line, I can run:
sudo update-grub
Then reboot, and everything is then fine. But can anyone tell me why sometimes it doesn't just work as part of the script?
Notes:
The goal is simply to remove the recovery mode boot option from the grub menu, with no user intervention other than running the script - the reasons for this are complex, but that's the way it is :)
The only difference between the 2 grub files should be the uncommenting of the line 'GRUB_DISABLE_RECOVERY="true"'
I cat the contents into the correct file (instead of cp'ing or mv'ing) because I figured it was the easiest way to ensure that file perms weren't messed up.
The process usually works, and rebooting the system removes the recovery mode grub menu option (as desired). But just sometimes ... doesn't work