Fix: wrong array index for boot commands

This commit is contained in:
natemaia 2018-12-15 22:32:18 -08:00
parent 84ed8947ae
commit 37f33c9a1a
4 changed files with 52 additions and 67 deletions

View File

@ -8,7 +8,6 @@
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
# command used to install each bootloader # command used to install each bootloader
declare -Ag BCMDS=( declare -Ag BCMDS=(
[syslinux]="syslinux-install_update -iam" [syslinux]="syslinux-install_update -iam"
[grub]="grub-install --recheck --force" [grub]="grub-install --recheck --force"
@ -30,20 +29,24 @@ declare -Ag BOOTLDRS=(
[UEFI]="systemd-boot ${BMNTS[UEFI-systemd-boot]} grub ${BMNTS[UEFI-grub]} syslinux ${BMNTS[UEFI-syslinux]}" [UEFI]="systemd-boot ${BMNTS[UEFI-systemd-boot]} grub ${BMNTS[UEFI-grub]} syslinux ${BMNTS[UEFI-syslinux]}"
) )
select_bootloader() setup_boot()
{ {
tput civis tput civis
if ! BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then if ! BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then
return 1 return 1
fi fi
[[ $BOOT_PART ]] && setup_boot_device if [[ $BOOT_PART != "" ]]; then
post_menu_${BOOTLDR} || return 1 mount_boot_part || return 1
setup_boot_device
fi
setup_${BOOTLDR} || return 1
} }
post_menu_grub() setup_grub()
{ {
FILES[9]="/etc/default/grub" EDIT_FILES[9]="/etc/default/grub"
if [[ $SYS == 'BIOS' ]]; then if [[ $SYS == 'BIOS' ]]; then
if [[ $BOOT_DEVICE == "" ]]; then if [[ $BOOT_DEVICE == "" ]]; then
@ -61,37 +64,55 @@ post_menu_grub()
local ttype="i386-efi" local ttype="i386-efi"
fi fi
# all the mount mess is needed to work properly in the chroot # the mount mess is needed for os-prober to work properly in the chroot
BCMDS[grub]="mkdir -p /run/udev && BCMDS[grub]="mkdir -p /run/udev && mkdir -p /run/lvm &&
mkdir -p /run/lvm && mount --bind /hostrun/udev /run/udev && mount --bind /hostrun/lvm /run/lvm &&
mount --bind /hostrun/udev /run/udev &&
mount --bind /hostrun/lvm /run/lvm &&
${BCMDS[grub]} --target=$ttype --efi-directory=${BMNTS[UEFI-grub]} --bootloader-id=$DIST && ${BCMDS[grub]} --target=$ttype --efi-directory=${BMNTS[UEFI-grub]} --bootloader-id=$DIST &&
umount /run/udev && umount /run/udev && umount /run/lvm"
umount /run/lvm"
fi fi
return 0 return 0
} }
post_menu_syslinux() setup_syslinux()
{ {
if [[ $SYS == 'BIOS' ]]; then if [[ $SYS == 'BIOS' ]]; then
FILES[9]="/boot/syslinux/syslinux.cfg" EDIT_FILES[9]="/boot/syslinux/syslinux.cfg"
if ! BCMDS[syslinux]="$(menubox "$_InstSysTitle" "$_InstSysBody" 0 0 0 \ if ! BCMDS[syslinux]="$(menubox "$_InstSysTitle" "$_InstSysBody" 0 0 0 \
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \ "syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
"syslinux-install_update -i" "Install to root partition (/)")"; then "syslinux-install_update -i" "Install to root partition (/)")"; then
return 1 return 1
fi fi
else else
FILES[9]="/boot/EFI/syslinux/syslinux.cfg" EDIT_FILES[9]="/boot/EFI/syslinux/syslinux.cfg"
BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST" BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
fi fi
} }
post_menu_systemd-boot() setup_systemd-boot()
{ {
FILES[9]="/boot/loader/entries/$DIST.conf" EDIT_FILES[9]="/boot/loader/entries/$DIST.conf"
}
setup_boot_device()
{
infobox "$_PrepMount" "\nSetting device flags for: $BOOT_PART\n" 1
if [[ $BOOT_PART = /dev/nvme* ]]; then
BOOT_DEVICE="${BOOT_PART%p[1-9]}"
else
BOOT_DEVICE="${BOOT_PART%[1-9]}"
fi
BOOT_PART_NUM="${BOOT_PART: -1}"
if [[ $SYS == 'UEFI' ]]; then
parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on >/dev/null 2>&1
else
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on >/dev/null 2>&1
fi
return 0
} }
prerun_grub() prerun_grub()

View File

@ -76,7 +76,7 @@ declare -Ag EDIT_FILES=(
show_cfg() show_cfg()
{ {
local cmd mnt pkgs local cmd mnt pkgs
cmd="${BCMDS[$SYS-$BOOTLDR]}" cmd="${BCMDS[$BOOTLDR]}"
mnt="${BMNTS[$SYS-$BOOTLDR]}" mnt="${BMNTS[$SYS-$BOOTLDR]}"
msgbox "$_PrepTitle" " msgbox "$_PrepTitle" "
@ -440,8 +440,7 @@ select_mirrorcmd()
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose" MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose"
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0 yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")" c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")"
c="$(json 'country_name' "${ip}?access_key=${key}&fields=country_name")"
MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate --verbose" MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate --verbose"
tput cnorm tput cnorm
@ -458,8 +457,7 @@ select_mirrorcmd()
'score': MirrorStatus score; 'score': MirrorStatus score;
'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")" 'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")"
else else
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")" c="$(json 'country_code' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_code")"
c="$(json 'country_code' "${ip}?access_key=${key}&fields=country_code")"
local w="https://www.archlinux.org/mirrorlist" local w="https://www.archlinux.org/mirrorlist"
if [[ $c ]]; then if [[ $c ]]; then
if [[ $c =~ (CA|US) ]]; then if [[ $c =~ (CA|US) ]]; then
@ -483,8 +481,11 @@ edit_configs()
fi fi
tput civis tput civis
local exitstr if [[ $DEBUG == true ]]; then
[[ $DEBUG == true ]] && exitstr="View debug log before the exit & reboot" || exitstr="Exit & reboot" local exitstr="View debug log before the exit & reboot"
else
local exitstr="Exit & reboot"
fi
SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \ SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \ --title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \
@ -495,29 +496,21 @@ edit_configs()
if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then
[[ $DEBUG == true && -r $DBG ]] && vim $DBG [[ $DEBUG == true && -r $DBG ]] && vim $DBG
# when die() is passed 127 as the exit code it will issue `systemctl -i reboot` # when die() is passed 127 it will call: systemctl -i reboot
die 127 die 127
else else
local existing_files="" local existing_files=""
for f in $(printf "%s" "${EDIT_FILES[$SELECTED]}"); do for f in $(printf "%s" "${EDIT_FILES[$SELECTED]}"); do
[[ -e ${MNT}$f ]] && existing_files+=" ${MNT}$f" [[ -e ${MNT}$f ]] && existing_files+=" ${MNT}$f"
done done
if [[ $existing_files ]]; then if [[ $existing_files ]]; then
if hash vim >/dev/null 2>&1; then vim -O $existing_files
vim -O $existing_files
else
for f in $existing_files; do
if hash nano >/dev/null 2>&1; then
nano "$f"
else
vi "$f"
fi
done
fi
else else
msgbox "$_ErrTitle" "$_NoFileErr" msgbox "$_ErrTitle" "$_NoFileErr"
fi fi
fi fi
edit_configs edit_configs
} }

View File

@ -42,15 +42,7 @@ mnt_menu()
select_boot_partition || { BOOT_PART=""; return 1; } select_boot_partition || { BOOT_PART=""; return 1; }
fi fi
if select_bootloader; then setup_boot || return 1
if [[ $BOOT_PART != "" ]]; then
mount_boot_part || return 1
fi
else
BOOTLDR=""
return 1
fi
select_swap || return 1 select_swap || return 1
select_extra_partitions || return 1 select_extra_partitions || return 1
return 0 return 0

View File

@ -340,24 +340,3 @@ find_partitions()
return 0 return 0
} }
setup_boot_device()
{
infobox "$_PrepMount" "\nSetting device flags for: $BOOT_PART\n" 1
if [[ $BOOT_PART = /dev/nvme* ]]; then
BOOT_DEVICE="${BOOT_PART%p[1-9]}"
else
BOOT_DEVICE="${BOOT_PART%[1-9]}"
fi
BOOT_PART_NUM="${BOOT_PART: -1}"
if [[ $SYS == 'UEFI' ]]; then
parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on >/dev/null 2>&1
else
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on >/dev/null 2>&1
fi
return 0
}