Add trap for ^C (SIGINT) to exit properly

This commit is contained in:
natemaia
2018-08-25 17:52:57 -07:00
parent 26c4ebd35e
commit 9188204758
11 changed files with 265 additions and 272 deletions

View File

@ -8,14 +8,13 @@
# Some ideas and code were taken from other installers
# AIF, ABIF, Calamares, Arch Wiki.. Credit where credit is due
# dry run performing no action, good for checking syntax errors
# set -n
# set -u
# set -v
# immutable variables {
readonly DIST="Archlabs" # Linux distributor
readonly VER="1.6.41" # Installer version
readonly VER="1.6.43" # Installer version
readonly LIVE="liveuser" # Live session user
readonly TRN="/usr/share/archlabs-installer" # Translation path
readonly MNT="/mnt/install" # Install mountpoint
@ -128,13 +127,14 @@ initialize_variables() {
declare -g WM_PACKAGES=""
declare -g EXTRA_PACKAGES=""
declare -g REMOVE_PKGS=""
declare -g CURRENT_MENU="main"
declare -g MENU_HIGHLIGHT=0
declare -g CURRENT_MENU=""
declare -g MENU_HIGHLIGHT
declare -g EDITOR_CHOICE=""
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
# boolean checks
declare -g AUTOLOGIN=false
declare -g CONFIG_DONE=false
# Commands used to install each bootloader.
# NOTE: syslinux and grub in particular can/will change during runtime
@ -196,7 +196,7 @@ set_debug() {
select_language() {
tput civis
local lang
lang=$(dialog --cr-wrap --stdout --backtitle "$DIST Installer - (x86_64)" \
lang=$(dialog --cr-wrap --stdout --backtitle "$DIST Installer - (x86_64) - Version $VER" \
--title " Select Language " --menu \
"\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" 0 0 0 \
"1" "English (en_**)" "2" "Español (es_ES)" \
@ -256,7 +256,7 @@ check_requirements() {
infobox "$_ErrTitle" "$_NotRoot\n$_Exit"
err=1
elif ! grep -qw 'lm' /proc/cpuinfo; then
infobox "$_ErrTitle" "\nSystem does not meet the minimum requirements, CPU must be x86_64 capable.\n$_Exit"
infobox "$_ErrTitle" "$_Not64Bit\n$_Exit"
err=1
elif ! (ping -c 1 archlinux.org || ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) >/dev/null 2>&1; then
([[ $(systemctl is-active NetworkManager) == "active" ]] && hash nmtui >/dev/null 2>&1) && { tput civis; nmtui; }
@ -287,16 +287,13 @@ check_for_errors() {
return 0
}
check_parts_are_mounted() {
[[ $(lsblk -o MOUNTPOINT) =~ "$MNT" ]] && return 0
msgbox "$_ErrTitle" "$_ErrNoMount"
return 1
}
check_base_unpacked() {
[[ -e $MNT/etc ]] && return 0
msgbox "$_ErrTitle" "$_ErrNoBase"
return 1
check_install_ready() {
if ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then
msgbox "$_ErrTitle" "$_ErrNoMount"; return 4
elif [[ $CONFIG_DONE != true ]]; then
msgbox "$_ErrTitle" "$_ErrNoConfig"; return 5
fi
return 0
}
getinput() {
@ -313,7 +310,7 @@ msgbox() {
infobox() {
local time="$3"
local bt="${BT:-$DIST Installer - (x86_64)}"
local bt="${BT:-$DIST Installer - (x86_64) - Version $VER}"
tput civis
dialog --cr-wrap --backtitle "$bt" --title " $1 " --infobox "$2\n" 0 0
sleep ${time:-2}
@ -337,7 +334,7 @@ yesno() {
wrap_up() {
yesno "$_CloseInst" "$1" "$2" "$3" || return 0
[[ $4 == "reboot" ]] && die 'reboot' || die 0
[[ $4 == 'reboot' ]] && die 'reboot' || die 0
}
die() {
@ -347,11 +344,15 @@ die() {
[[ $1 =~ [0-9] ]] && exit $1 || systemctl $1
}
sigint() {
echo -e "\n** CTRL-C caught"
die 1
}
oneshot() {
local func="$1"
[[ -e /tmp/.ai.$func ]] && return 0
[[ -e /tmp/.ai_$1 || ! $(type $1) ]] && return 0
$1 || return 1
touch "/tmp/.ai.$func"
touch "/tmp/.ai_$1"
return 0
}
@ -362,19 +363,27 @@ oneshot() {
set_keymap() {
tput civis
declare -g KEYMAP
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepLayout " \
--menu "$_XMapBody" 20 70 12 $KEYMAPS)"
KEYMAP="$(dialog --cr-wrap --stdout \
--backtitle "$DIST Installer - (x86_64) - Version $VER" \
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 $KEYMAPS)"
[[ $? != 0 || $KEYMAP == "" ]] && return 1
# when a matching console map is not available open a selection dialog
if ! [[ $CONSOLE_MAPS =~ "$KEYMAP -" ]]; then
tput civis
CONSOLE_MAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
CONSOLE_MAP="$(dialog --cr-wrap --stdout \
--backtitle "$DIST Installer - (x86_64) - Version $VER" \
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
else
CONSOLE_MAP="$KEYMAP"
fi
setxkbmap $XKBMAP >/dev/null 2>&1
if [[ $DISPLAY && $TERM != 'linux' ]]; then
(type setxkbmap >/dev/null 2>&1) && setxkbmap $KEYMAP >/dev/null 2>&1
else
(type loadkeys >/dev/null 2>&1) && loadkeys $CONSOLE_MAP >/dev/null 2>&1
fi
return 0
}
@ -418,76 +427,6 @@ set_hostname() {
return 0
}
create_user() {
infobox "$_ConfRoot" "\nSetting root password\n" 1
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd" 2>$ERR
check_for_errors "chpasswd root"
infobox "$_ConfUser" "$_UserSetBody" 1
swap_livuser
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd" 2>$ERR
check_for_errors "chpasswd $NEWUSER"
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER" 2>$ERR
check_for_errors "chown -Rf $NEWUSER:users /home/$NEWUSER"
setup_user_home
return 0
}
swap_livuser() {
# edit the required files in /etc/ to swap the liveuser account name
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
# set standard groups for the new user
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
if [[ $AUTOLOGIN == true && $LOGIN_TYPE == 'lightdm' ]]; then
# add the nopasswdlogin group for lightdm autologin
groups="$groups,nopasswdlogin"
elif [[ $AUTOLOGIN == true ]]; then
# setup autologin on tty1 with systemd + xinit
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/systemd/system/getty@tty1.service.d/autologin.conf
fi
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER" 2>$ERR
check_for_errors "mv -f /home/$LIVE /home/$NEWUSER"
chroot_cmd "usermod -aG $groups $NEWUSER" 2>$ERR
check_for_errors "usermod -aG $groups $NEWUSER"
return 0
}
setup_user_home() {
local user_home="$MNT/home/$NEWUSER"
sed -i "s/${LIVE}/${NEWUSER}/g" $user_home/.config/gtk-3.0/bookmarks \
$user_home/.mozilla/firefox/{archlabs.default/prefs.js,archlabs.default/sessionstore.js}
rm -rf $user_home/.config/awesome
if [[ $AUTOLOGIN == true ]]; then
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
rm -rf $user_home/.{zprofile,xinitrc}
else
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
fi
else
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
fi
if ! [[ $INSTALL_WMS =~ openbox ]]; then
rm -rf $user_home/.config/{openbox,ob-autostart,obmenu-generator}
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
rm -rf $user_home/.config/{bspwm,sxhkd}
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
rm -rf $user_home/.config/i3
fi
return 0
}
user_setup() {
tput cnorm
@ -756,7 +695,7 @@ mount_partition() {
fi
confirm_mount $part "$mount" || return 1
check_part_is_crypt_or_lvm "$part"
check_cryptlvm "$part"
return 0
}
@ -944,7 +883,7 @@ enable_swap() {
mkswap $swap >/dev/null 2>$ERR
check_for_errors "mkswap $swap"
swapon $swap >/dev/null 2>$ERR
check_for_error "swapon $swap" || return 1
check_for_error "swapon $swap"
return 0
}
@ -956,10 +895,10 @@ select_swap() {
if [[ $SWAP == "$_SelSwpFile" ]]; then
swapfile_size || return 1
enable_swap "$MNT/swapfile" || return 1
enable_swap "$MNT/swapfile"
SWAP="/swapfile"
else
enable_swap "$SWAP" || return 1
enable_swap "$SWAP"
decrease_part_count "$SWAP"
fi
@ -1065,6 +1004,22 @@ select_boot_setup() {
return 0
}
setup_boot_device() {
# set BOOT_DEVICE for syslinux on UEFI and grub on BIOS
BOOT_DEVICE="${BOOT_PART%%([1-9]|(p)[1-9])}"
BOOT_PART_NUM="${BOOT_PART: -1}"
# setup the needed partition flags for boot on both system types
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on 2>$ERR
check_for_errors "parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on"
if [[ $SYS == 'UEFI' ]]; then
parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on 2>$ERR
check_for_errors "parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on"
fi
return 0
}
select_efi_partition() {
format_efi_as_vfat() {
infobox "$_FSTitle" "\nFormatting $1 as vfat/fat32.\n" 0
@ -1072,30 +1027,29 @@ select_efi_partition() {
check_for_errors "mkfs.vfat -F32 $1"
}
tput civis
if (( COUNT == 1 )); then
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_PrepMount" "$_OnlyOne for EFI: $BOOT_PART\n" 1
else
tput civis
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepMount " \
--menu "$_SelUefiBody" 0 0 0 $PARTS)"
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelUefiBody" 0 0 0 $PARTS)"
[[ $? != 0 || $BOOT_PART == "" ]] && return 1
fi
if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormUefiBody $BOOT_PART $_FormUefiBody2"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format_efi_as_vfat "$BOOT_PART" || return 1
fi
yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Do Not Format" "no" &&
format_efi_as_vfat "$BOOT_PART"
else
format_efi_as_vfat "$BOOT_PART" || return 1
format_efi_as_vfat "$BOOT_PART"
fi
setup_boot_device
return 0
}
select_bios_boot_partition() {
select_boot_partition() {
format_as_ext4() {
infobox "$_FSTitle" "\nFormatting $1 as ext4.\n" 0
mkfs.ext4 -q "$1" >/dev/null 2>$ERR
@ -1103,8 +1057,8 @@ select_bios_boot_partition() {
}
tput civis
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title "$_PrepMount" \
--menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)"
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title "$_PrepMount" --menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)"
if [[ $BOOT_PART == "$_Skip" || $BOOT_PART == "" ]]; then
BOOT_PART=""
@ -1112,31 +1066,33 @@ select_bios_boot_partition() {
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormBiosBody $BOOT_PART $_FormUefiBody2"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format_as_ext4 "$BOOT_PART" || return 1
format_as_ext4 "$BOOT_PART"
fi
else
format_as_ext4 "$BOOT_PART" || return 1
format_as_ext4 "$BOOT_PART"
fi
# set BOOT_DEVICE for grub on BIOS systems and syslinux on UEFI
BOOT_DEVICE="${BOOT_PART%%([1-9]|(p)[1-9])}"
BOOT_PART_NUM="${BOOT_PART: -1}"
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on 2>$ERR
check_for_errors "parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on"
setup_boot_device
fi
return 0
}
select_root_partition() {
# if we used LUKS and no LVM or LUKS+LVM
# remove the relevant partition labels from the list
if (( LUKS == 1 && LVM == 0 )); then
ROOT_PART="/dev/mapper/$LUKS_NAME"
decrease_part_count "$LUKS_PART"
elif (( LUKS == 1 && LVM == 1 )); then
decrease_part_count "$LUKS_PART"
decrease_part_count "/dev/mapper/$LUKS_NAME"
for part in $(echo "$GROUP_PARTS"); do
decrease_part_count "$part"
done
ROOT_PART=""
elif (( LUKS == 0 && LVM == 1 )); then
for part in $(echo "$GROUP_PARTS"); do
decrease_part_count "$part"
done
ROOT_PART=""
fi
@ -1194,7 +1150,7 @@ select_extra_partitions() {
return 0
}
select_install_partitions() {
select_partitions() {
msgbox "$_PrepMount" "$_WarnMount"
lvm_detect
@ -1210,8 +1166,8 @@ select_install_partitions() {
if [[ $BOOT_PART == "" ]]; then
if [[ $SYS == "UEFI" ]]; then
select_efi_partition || { BOOT_PART=""; return 1; }
elif (( COUNT > 0 )); then
select_bios_boot_partition || { BOOT_PART=""; return 1; }
elif (( $COUNT > 0 )); then
select_boot_partition || { BOOT_PART=""; return 1; }
fi
else
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n" 1
@ -1230,7 +1186,7 @@ select_install_partitions() {
return 0
}
check_part_is_crypt_or_lvm() {
check_cryptlvm() {
local part="$1"
local devs="$(lsblk -lno NAME,FSTYPE,TYPE)"
@ -1297,7 +1253,7 @@ luks_open() {
fi
# get password and name for encryption
luks_input_values "$_LuksOpen" "$LUKS_NAME" || return 1
luks_pass "$_LuksOpen" "$LUKS_NAME" || return 1
infobox "$_LuksOpen" "$_LuksWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
echo "$LUKS_PASS" | cryptsetup open --type luks "$LUKS_PART" "$LUKS_NAME" 2>$ERR
@ -1308,10 +1264,11 @@ luks_open() {
return 0
}
luks_input_values() {
luks_pass() {
local title="$1"
local name="$2"
LUKS_PASS=""
LUKS_NAME=""
tput cnorm
@ -1331,7 +1288,7 @@ luks_input_values() {
if [[ $pass == "" || "$pass" != "$pass2" ]]; then
msgbox "$_ErrTitle" "$_PassErr\n$_TryAgain"
luks_input_values "$title" "$name" || return 1
luks_pass "$title" "$name" || return 1
fi
LUKS_PASS="$pass"
@ -1363,7 +1320,7 @@ luks_setup() {
fi
# get password and name for encrypted device
luks_input_values "$_LuksEncrypt" "$LUKS_NAME" || return 1
luks_pass "$_LuksEncrypt" "$LUKS_NAME" || return 1
return 0
}
@ -1382,7 +1339,7 @@ luks_default() {
return 0
}
luks_cipher_key() {
luks_keycmd() {
if luks_setup; then
tput cnorm
local cipher
@ -1424,7 +1381,7 @@ luks_menu() {
case $choice in
"$_LuksEncrypt") luks_default && return 0 ;;
"$_LuksOpen") luks_open && return 0 ;;
"$_LuksEncryptAdv") luks_cipher_key && return 0 ;;
"$_LuksEncryptAdv") luks_keycmd && return 0 ;;
*) return 0
esac
@ -1729,16 +1686,23 @@ lvm_menu() {
## Install Functions ##
######################################################################
install_main() {
config_install() {
# whether to use a custom mirror sorting command later
oneshot set_hostname || return 1
oneshot set_locale || return 1
oneshot set_timezone || return 1
oneshot user_setup || return 1
oneshot mirrorlist_cmd || return 1
oneshot window_manager || return 1 # choose which window managers/desktop environment to install
oneshot window_manager || return 1
oneshot extra_packages || return 1
oneshot choose_kernel
CONFIG_DONE=true
return 0
}
install_main() {
# this assumes all needed variables/settings are setup as needed
# no additional user confirmation are performed aside from what is needed
# unpack the whole filesystem to install directory $MNT
oneshot install_base
@ -1761,8 +1725,8 @@ install_main() {
run_mkinitcpio || return 1
install_bootloader || return 1
oneshot set_hwclock
oneshot create_user || return 1
oneshot set_hwclock
oneshot edit_configs
return 0
@ -1944,6 +1908,76 @@ setup_lightdm() {
fi
}
create_user() {
infobox "$_ConfRoot" "\nSetting root password\n" 1
chroot_cmd "echo 'root:$ROOT_PASS' | chpasswd" 2>$ERR
check_for_errors "chpasswd root"
infobox "$_ConfUser" "$_UserSetBody" 1
swap_livuser
chroot_cmd "echo '$NEWUSER:$USER_PASS' | chpasswd" 2>$ERR
check_for_errors "chpasswd $NEWUSER"
chroot_cmd "chown -Rf $NEWUSER:users /home/$NEWUSER" 2>$ERR
check_for_errors "chown -Rf $NEWUSER:users /home/$NEWUSER"
setup_user_home
return 0
}
swap_livuser() {
# edit the required files in /etc/ to swap the liveuser account name
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
# set standard groups for the new user
local groups="rfkill,wheel,network,lp,storage,power,video,audio,lp,autologin"
if [[ $AUTOLOGIN == true && $LOGIN_TYPE == 'lightdm' ]]; then
# add the nopasswdlogin group for lightdm autologin
groups="$groups,nopasswdlogin"
elif [[ $AUTOLOGIN == true ]]; then
# setup autologin on tty1 with systemd + xinit
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/systemd/system/getty@tty1.service.d/autologin.conf
fi
chroot_cmd "mv -f /home/$LIVE /home/$NEWUSER" 2>$ERR
check_for_errors "mv -f /home/$LIVE /home/$NEWUSER"
chroot_cmd "usermod -aG $groups $NEWUSER" 2>$ERR
check_for_errors "usermod -aG $groups $NEWUSER"
return 0
}
setup_user_home() {
local user_home="$MNT/home/$NEWUSER"
sed -i "s/${LIVE}/${NEWUSER}/g" $user_home/.config/gtk-3.0/bookmarks \
$user_home/.mozilla/firefox/{archlabs.default/prefs.js,archlabs.default/sessionstore.js}
rm -rf $user_home/.config/awesome
if [[ $AUTOLOGIN == true ]]; then
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
rm -rf $user_home/.{zprofile,xinitrc}
else
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
fi
else
sed -i '/archlabs-installer/d' $user_home/.zprofile
echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null' >> $user_home/.zprofile
sed -i "s/:-openbox/:-${LOGIN_WM}/g" $user_home/.xinitrc
fi
if ! [[ $INSTALL_WMS =~ openbox ]]; then
rm -rf $user_home/.config/{openbox,ob-autostart,obmenu-generator}
elif ! [[ $INSTALL_WMS =~ bspwm ]]; then
rm -rf $user_home/.config/{bspwm,sxhkd}
elif ! [[ $INSTALL_WMS =~ i3-gaps ]]; then
rm -rf $user_home/.config/i3
fi
return 0
}
update_mirrorlist() {
$MIRROR_CMD --verbose --save $MNT/etc/pacman.d/mirrorlist && return 0
infobox "$_ErrTitle" "\nAn error occurred while updating the mirrorlist.\n\nFalling back to automatic sorting...\n"
@ -2154,11 +2188,9 @@ edit_configs() {
((MENU_HIGHLIGHT++))
fi
local msg="${_Final}$_EditBody"
tput civis
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_EditTitle " \
--default-item $MENU_HIGHLIGHT --menu "$msg" 0 0 0 \
--default-item $MENU_HIGHLIGHT --menu "${_Final}$_EditBody" 0 0 0 \
"1" "$_Done" "2" "keymaps" "3" "locale" "4" "hostname" "5" "sudoers" \
"6" "mkinitcpio.conf" "7" "fstab" "8" "crypttab" "9" "$BOOTLOADER" "10" "pacman.conf")
if [[ $MENU_HIGHLIGHT == "" || $MENU_HIGHLIGHT == 1 ]]; then
@ -2171,7 +2203,7 @@ edit_configs() {
done
if [[ $existing_files != "" ]]; then
if [[ $DISPLAY ]] && hash geany >/dev/null 2>&1; then
if [[ $DISPLAY && $TERM != 'linux' ]] && hash geany >/dev/null 2>&1; then
geany -i $existing_files
else
vim -O $existing_files
@ -2185,42 +2217,49 @@ edit_configs() {
}
main() {
if [[ $ROOT_PART != "" && $BOOTLOADER != "" && ($SYS == "BIOS" || $BOOT_PART != "") ]]; then
# if at least one partition is NOT mounted at $MNT bail
check_parts_are_mounted || return 1
# this is where all the action happens, the rest is mostly automated
# once the needed steps are done, this will begin the install
install_main || return 1
fi
if [[ $CURRENT_MENU != "main" ]]; then
MENU_HIGHLIGHT=1
CURRENT_MENU="main"
elif (( MENU_HIGHLIGHT < 8 )); then
((MENU_HIGHLIGHT++))
((MENU_HIGHLIGHT++)) # increment the highlighted menu item
fi
tput civis
MENU_HIGHLIGHT=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepTitle " \
--default-item $MENU_HIGHLIGHT --menu "$_PrepBody" 0 0 0 \
"1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \
"5" "$_PrepMount" "6" "$_InstTitle" "7" "$_Done")
MENU_HIGHLIGHT=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_PrepTitle " --default-item $MENU_HIGHLIGHT --menu "$_PrepBody" 0 0 0 \
"1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \
"5" "$_PrepMount" "6" "$_PrepConfig" "7" "$_InstTitle" "8" "$_Done")
# if trying to install the system, make sure the partitions are mounted first
([[ -n $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 6 ]] && ! check_parts_are_mounted) && { MENU_HIGHLIGHT=5; return 1; }
# if trying to install the system, make sure the partitions are mounted
# and that the needed config variables and user variables have been set up
if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 7 ]]; then
check_install_ready
local return_val=$?
if [[ $return_val -gt 0 ]]; then
# when check_install_ready() returns (value > 0) we set the next menu highlight
# to (missing step - 1) due to the value being incremented at the beginning
# so the missing step is highlighted automatically during the next run
MENU_HIGHLIGHT=$return_val
return 1 # were inside of a (while true) loop, so returning loops the menu again
fi
fi
case $MENU_HIGHLIGHT in
1) show_devices ;;
2) unmount_partitions && select_device 'root' && create_partitions "$DEVICE" ;;
3) luks_menu ;;
4) lvm_menu ;;
5) select_install_partitions ;;
6) install_main ;;
5) select_partitions ;;
6) config_install ;;
7) install_main ;;
*) wrap_up "$_CloseInstBody" 'Exit' 'Back' 'exit'
esac
}
# trap ctrl-c and call sigint() to properly exit, without this
# exiting via Ctrl-c can leave the terminal in a messed up state
trap sigint INT
for arg in "$@"; do
[[ $arg == "--debug" || $arg == "-d" ]] && set_debug
done