3 # This file is part of the 'dragora-installer'.
5 # Purpose: Installation of GRUB boot loader into /media/dragora-root.
7 # Exit immediately on any error
10 # Make sure to have /proc and /dev available to install GRUB
11 if ! mountpoint
-q /media
/dragora-root
/dev
13 mount
--bind /dev
/media
/dragora-root
/dev
15 if ! mountpoint
-q /media
/dragora-root
/proc
17 mount
-t proc proc
/media
/dragora-root
/proc
19 if ! mountpoint
-q /media
/dragora-root
/sys
21 mount
-t sysfs sysfs
/media
/dragora-root
/sys
24 # Loop for the main menu
28 --backtitle "\ZbBoot loader installation" \
29 --title "GRand Unified Bootloader" \
30 --default-button "${_default_button:-ok}" \
31 --ok-label "Install / Reinstall" \
32 --cancel-label "Ignore & Continue" \
34 "It's time to install a boot loader (GNU GRUB).\n\n\
35 If you do not have a boot loader, it is recommended to install it in\n\
36 the Master Boot Record (MBR). It is possible to overwrite your current \
38 You can also install the boot loader on the Root partition (superblock), \
39 but note that the partition needs the boot flag to boot. If you have not \
40 used this flag before when you created the partitions you can do so later \
41 by invoking 'cfdisk' or 'fdisk'." 19 72 2 \
42 "0" "Install GRUB on the Master Boot Record" \
43 "1" "Install GRUB on the Super block" \
44 2> ${SUBTMPDIR}/return-MenuBootloader || _status
=$?
45 if test -n "$_status" && test $_status -gt 0
47 if test $_status -eq 1
49 # Ignore exit status on 'cancel'
52 # Any other dialogs code.
56 answer
="$(cat -- ${SUBTMPDIR}/return-MenuBootloader)"
58 # Check for selected options
60 0 |
1) ## Master Boot Record or Super block
62 # Defining the title of the subsequent menu
65 _submenu_title
="Master Boot Record"
67 _submenu_title
="Super block"
70 # Check if it is a logical volume
73 array
=( $
(pvs
--ignorelockingfailure --noheadings |
awk '{ print $1 }') )
75 # Verify on which partition to install
76 if (( ${#array[*]} > 1 ))
78 i
=0 ; for partition
in "${array[@]}"
80 partition
="${partition/[0-9]*/}"
86 # Remove possible duplicate elements
87 xlist
=( $
(echo "${xlist[@]}" |
awk '!s[$0]++') )
90 --backtitle "\ZbBoot loader installation" \
91 --title "$_submenu_title" \
93 "More than one disk or partition has been detected.\n\n\
94 Please select the boot loader destination:" 0 0 0 "${xlist[@]}" \
95 2> ${SUBTMPDIR}/return-MenuBootloader_cases ||
continue;
96 BOOT_DEVICE
="$(cat -- ${SUBTMPDIR}/return-MenuBootloader_cases)"
98 BOOT_DEVICE
="${array[0]}"
105 # To fallback if 'BOOT_DEVICE' is not defined, null
106 BOOT_DEVICE
="${BOOT_DEVICE:=$(cat -- ${SUBTMPDIR}/root_device)}"
108 # If the super block was not chosen, we don't need
109 # the device number to install in the MBR
110 if test "$answer" != 1
112 BOOT_DEVICE
="${BOOT_DEVICE/[0-9]*/}"
118 --backtitle "\ZbGRUB: Installing the boot loader" \
119 --title "Installing GRUB on $BOOT_DEVICE" \
121 "chroot /media/dragora-root /usr/sbin/grub-install --force $BOOT_DEVICE && echo \"^ Return status = $?\ " $
(( $LINES - 8 )) $COLUMNS
125 --backtitle "\ZbGRUB: Generating configuration file" \
126 --title "Generating grub.cfg" \
128 "chroot /media/dragora-root /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg && echo \"^ Return status = $?\"" $
(( $LINES - 8 )) $COLUMNS
131 _default_button
=cancel