grub_install: use same method for checking grub-install and update-grub
authorChris Hofstaedtler <chris@hofstaedtler.name>
Mon, 13 Nov 2023 22:30:33 +0000 (23:30 +0100)
committerChris Hofstaedtler <chris@hofstaedtler.name>
Fri, 17 Nov 2023 15:25:08 +0000 (16:25 +0100)
chroot-script

index ad23449..8f8e5ff 100755 (executable)
@@ -717,6 +717,10 @@ grub_install() {
      echo "Error: grub-install not available. (Error while installing grub package?)" >&2
      return 1
   fi
+  if ! [ -x "$(command -v update-grub)" ] ; then
+     echo "Error: update-grub not available. (Error while installing grub package?)" >&2
+     return 1
+  fi
 
   if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
      for device in $SELECTED_PARTITIONS ; do
@@ -741,16 +745,6 @@ grub_install() {
 
   echo "Adjusting grub configuration for use on ${GRUB}."
 
-  # finally install grub
-  if [ -x /usr/sbin/update-grub ] ; then
-     UPDATEGRUB='/usr/sbin/update-grub'
-  elif [ -x /sbin/update-grub ] ; then
-     UPDATEGRUB='/sbin/update-grub'
-  else
-    echo "Error: update-grub not available, can not execute it." >&2
-    return 1
-  fi
-
   if [ -n "${BOOT_APPEND}" ] ; then
     echo "Adding BOOT_APPEND configuration ['${BOOT_APPEND}'] to /etc/default/grub."
     sed -i "/GRUB_CMDLINE_LINUX_DEFAULT/ s#\"\$# ${BOOT_APPEND}\"#" /etc/default/grub
@@ -758,7 +752,8 @@ grub_install() {
 
   mountpoint /boot/efi &>/dev/null && umount /boot/efi
 
-  $UPDATEGRUB
+  # finally install grub. Existence of update-grub is checked above.
+  update-grub
 }
 # }}}