1

I want to run a script automatically after every grub-update. The script itself consists of a single line

sed -i 's/[\]"!Windows 2006[\]"/"!Windows 2006"/g' /boot/grub/grub.cfg

For this purpose, I edited the already existing file

/etc/grub.d/40_custom

to read as follows:

#!/bin/sh
set -e
sed -i 's/[\]"!Windows 2006[\]"/"!Windows 2006"/g' /boot/grub/grub.cfg

This, however doesn't seem to work and I can't figure out why.

6
  • Just add a line like touch /tmp/grubtest and run update-grub. Is the file create? Mar 22, 2015 at 10:48
  • Scripts in /etc/grub.d are run as part of creating grub.cfg. I doubt you can process that file while it is being created.
    – muru
    Mar 22, 2015 at 11:59
  • I tried to edit the /usr/sbin/update-grub and the /usr/sbin/grub-mkconfig which it executes and add a simple echo command to each of the scripts, but they were not processed for some reason. Are those scripts cached somewhere so that the changes did not affect the executed commands or is anything in there that terminates the script before reaching the last line?
    – Byte Commander
    Mar 22, 2015 at 14:13
  • @davidbaumann touch /tmp/grubtest works just fine. @muru maybe you are right. do you guys have some alternative? Mar 22, 2015 at 19:35
  • Just add cp /boot/grub/grub.cfg /tmp/grub.cfg. So you can see what's inside the grub file after running sed. Mar 22, 2015 at 19:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.