Fix: wrong array index for boot commands
This commit is contained in:
parent
84ed8947ae
commit
37f33c9a1a
@ -8,7 +8,6 @@
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
# command used to install each bootloader
|
||||
|
||||
declare -Ag BCMDS=(
|
||||
[syslinux]="syslinux-install_update -iam"
|
||||
[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]}"
|
||||
)
|
||||
|
||||
select_bootloader()
|
||||
setup_boot()
|
||||
{
|
||||
tput civis
|
||||
if ! BOOTLDR="$(menubox "$_PrepMount" "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
[[ $BOOT_PART ]] && setup_boot_device
|
||||
post_menu_${BOOTLDR} || return 1
|
||||
if [[ $BOOT_PART != "" ]]; then
|
||||
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 [[ $BOOT_DEVICE == "" ]]; then
|
||||
@ -61,37 +64,55 @@ post_menu_grub()
|
||||
local ttype="i386-efi"
|
||||
fi
|
||||
|
||||
# all the mount mess is needed to work properly in the chroot
|
||||
BCMDS[grub]="mkdir -p /run/udev &&
|
||||
mkdir -p /run/lvm &&
|
||||
mount --bind /hostrun/udev /run/udev &&
|
||||
mount --bind /hostrun/lvm /run/lvm &&
|
||||
# the mount mess is needed for os-prober to work properly in the chroot
|
||||
BCMDS[grub]="mkdir -p /run/udev && mkdir -p /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 &&
|
||||
umount /run/udev &&
|
||||
umount /run/lvm"
|
||||
umount /run/udev && umount /run/lvm"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
post_menu_syslinux()
|
||||
setup_syslinux()
|
||||
{
|
||||
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 \
|
||||
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
|
||||
"syslinux-install_update -i" "Install to root partition (/)")"; then
|
||||
return 1
|
||||
fi
|
||||
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"
|
||||
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()
|
||||
|
@ -76,7 +76,7 @@ declare -Ag EDIT_FILES=(
|
||||
show_cfg()
|
||||
{
|
||||
local cmd mnt pkgs
|
||||
cmd="${BCMDS[$SYS-$BOOTLDR]}"
|
||||
cmd="${BCMDS[$BOOTLDR]}"
|
||||
mnt="${BMNTS[$SYS-$BOOTLDR]}"
|
||||
msgbox "$_PrepTitle" "
|
||||
|
||||
@ -440,8 +440,7 @@ select_mirrorcmd()
|
||||
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose"
|
||||
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
|
||||
|
||||
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
|
||||
c="$(json 'country_name' "${ip}?access_key=${key}&fields=country_name")"
|
||||
c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")"
|
||||
MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate --verbose"
|
||||
|
||||
tput cnorm
|
||||
@ -458,8 +457,7 @@ select_mirrorcmd()
|
||||
'score': MirrorStatus score;
|
||||
'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")"
|
||||
else
|
||||
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
|
||||
c="$(json 'country_code' "${ip}?access_key=${key}&fields=country_code")"
|
||||
c="$(json 'country_code' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_code")"
|
||||
local w="https://www.archlinux.org/mirrorlist"
|
||||
if [[ $c ]]; then
|
||||
if [[ $c =~ (CA|US) ]]; then
|
||||
@ -483,8 +481,11 @@ edit_configs()
|
||||
fi
|
||||
|
||||
tput civis
|
||||
local exitstr
|
||||
[[ $DEBUG == true ]] && exitstr="View debug log before the exit & reboot" || exitstr="Exit & reboot"
|
||||
if [[ $DEBUG == true ]]; then
|
||||
local exitstr="View debug log before the exit & reboot"
|
||||
else
|
||||
local exitstr="Exit & reboot"
|
||||
fi
|
||||
|
||||
SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \
|
||||
@ -495,29 +496,21 @@ edit_configs()
|
||||
|
||||
if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then
|
||||
[[ $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
|
||||
else
|
||||
local existing_files=""
|
||||
for f in $(printf "%s" "${EDIT_FILES[$SELECTED]}"); do
|
||||
[[ -e ${MNT}$f ]] && existing_files+=" ${MNT}$f"
|
||||
done
|
||||
|
||||
if [[ $existing_files ]]; then
|
||||
if hash vim >/dev/null 2>&1; then
|
||||
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
|
||||
vim -O $existing_files
|
||||
else
|
||||
msgbox "$_ErrTitle" "$_NoFileErr"
|
||||
fi
|
||||
fi
|
||||
|
||||
edit_configs
|
||||
}
|
||||
|
||||
|
@ -42,15 +42,7 @@ mnt_menu()
|
||||
select_boot_partition || { BOOT_PART=""; return 1; }
|
||||
fi
|
||||
|
||||
if select_bootloader; then
|
||||
if [[ $BOOT_PART != "" ]]; then
|
||||
mount_boot_part || return 1
|
||||
fi
|
||||
else
|
||||
BOOTLDR=""
|
||||
return 1
|
||||
fi
|
||||
|
||||
setup_boot || return 1
|
||||
select_swap || return 1
|
||||
select_extra_partitions || return 1
|
||||
return 0
|
||||
|
@ -340,24 +340,3 @@ find_partitions()
|
||||
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user