More recursion refactoring, update dialog text

This commit is contained in:
natemaia
2019-01-20 05:12:48 -08:00
parent 8c85cc08af
commit e6e52af3cb
2 changed files with 228 additions and 297 deletions

View File

@ -32,9 +32,9 @@ LOGIN_TYPE="" # login manager can be lightdm or xinit
INSTALL_WMS="" # space separated list of chosen wm/de
KERNEL="linux" # can be linux, linux-lts, linux-zen, or linux-hardened
MYSHELL="" # login shell for root and the primary user
PACKAGES="" # list of all packages to install including WM_PACKAGES
PACKAGES="" # list of all packages to install including WM_PKGS
USER_PKGS="" # packages selected by the user during install
WM_PACKAGES="" # full list of packages added during wm/de choice
WM_PKGS="" # full list of packages added during wm/de choice
HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf
FONT="ter-i16n" # font used in the linux console
UCODE="" # cpu manufacturer microcode filename (if any)
@ -57,15 +57,16 @@ CONFIG_DONE=false # basic configuration is finished
BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352
CHECKED_NET=false # have we checked the network connection already
AUTO_ROOT_PART="" # values from auto partition
AUTO_BOOT_PART=""
AUTO_ROOT_PART="" # root value from auto partition
AUTO_BOOT_PART="" # boot value from auto partition
FORMATTED="" # partitions we formatted and should allow skipping
# sane baseline
# baseline
BASE_PKGS="archlabs-scripts archlabs-skel-base archlabs-themes archlabs-dARK archlabs-icons archlabs-wallpapers "
BASE_PKGS+="base-devel xorg xorg-drivers sudo git gvfs gtk3 gtk-engines gtk-engine-murrine pavucontrol tumbler "
BASE_PKGS+="playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-base gst-plugins-good"
# sane extras for window managers
# extras for window managers
WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip exo "
WM_BASE_PKGS+="xdotool compton wmctrl gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect"
@ -102,6 +103,7 @@ CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
# make sure these are defined for some dialog size calculation
[[ $LINES ]] || LINES=$(tput lines)
[[ $COLUMNS ]] || COLUMNS=$(tput cols)
SHL=$((LINES - 20))
# various associative arrays
# {
@ -225,10 +227,10 @@ main()
case $SEL in
1) device_tree ;;
2) partition_menu || (( SEL-- )) ;;
2) part_menu || (( SEL-- )) ;;
3) luks_menu || (( SEL-- )) ;;
4) lvm_menu || (( SEL-- )) ;;
5) mounting_menu || (( SEL-- )) ;;
5) mount_menu || (( SEL-- )) ;;
6) prechecks 0 && { mkuser || (( SEL-- )); } ;;
7) prechecks 1 && { cfg_menu || (( SEL-- )); } ;;
8) prechecks 2 && { select_sessions || (( SEL-- )); } ;;
@ -245,7 +247,7 @@ main()
show_cfg()
{
local cmd="${BCMDS[$BOOTLDR]}"
local mnt="/boot"
[[ $BOOT_PART ]] && local mnt="/boot" || local mnt="none"
local pkgs="${USER_PKGS# }"
pkgs="${pkgs% }"
pkgs="${pkgs% } ${PACKAGES# }"
@ -268,8 +270,8 @@ show_cfg()
LVM: ${LVM:-none}
LUKS: ${LUKS:-none}
Extra Mounts: ${EXMNTS:-${EXMNT:-none}}
Mkinit Hooks: ${HOOKS:-none}
Extra: ${EXMNTS:-${EXMNT:-none}}
Hooks: ${HOOKS:-none}
---------- BOOTLOADER CONFIGURATION -----------
@ -307,29 +309,23 @@ show_cfg()
cfg_menu()
{
local err=0
tput civis
if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"; then
return 1
fi
MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"
[[ $MYSHELL ]] || return 1
tput cnorm
if ! HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"; then
return 1
fi
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
[[ $HOSTNAME ]] || return 1
tput civis
if ! LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $((LINES - 20)) $LOCALES)"; then
return 1
fi
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $SHL $LOCALES)"
[[ $LOCALE ]] || return 1
select_timezone || return 1
KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" \
'linux' 'Vanilla Linux kernel and modules, with a few patches applied.' \
'linux-lts' 'Long-term support (LTS) Linux kernel and modules.' \
'linux-zen' 'A collaborative effort of kernel hackers to provide the best Linux kernel for everyday systems' \
'linux-hardened' 'A security-focused Linux kernel with hardening patches to mitigate kernel and userspace exploits')"
err=$?
(( err == 0 )) || return 1
[[ $KERNEL ]] || return 1
select_mirrorcmd || return 1
CONFIG_DONE=true
return 0
@ -386,7 +382,7 @@ select_keymap()
{
tput civis
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepLayout " --menu "$_XMapBody" 0 0 $((LINES - 20)) \
--title " $_PrepLayout " --menu "$_XMapBody" 0 0 $SHL \
'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \
'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \
'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \
@ -409,13 +405,10 @@ select_keymap()
'me' 'Montenegrin')"
[[ $KEYMAP ]] || return 1
if [[ $CMAPS == *"$KEYMAP"* ]]; then
CMAP="$KEYMAP"
else
CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_CMapTitle " --menu "$_CMapBody" 0 0 $((LINES - 17)) $CMAPS)"
CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_CMapTitle " --menu "$_CMapBody" 0 0 $SHL $CMAPS)"
[[ $CMAP ]] || return 1
fi
@ -430,27 +423,29 @@ select_keymap()
select_timezone()
{
# create associative array for SUBZONES[zone]
local f="/usr/share/zoneinfo/zone.tab"
declare -A SUBZONES
local f="/usr/share/zoneinfo/zone.tab" err=0
declare -A subz
for i in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
SUBZONES[$i]="$(awk '/'"$i"'\// {gsub(/'"$i"'\//, ""); print $3, $1}' $f | sort)"
subz[$i]="$(awk '/'"$i"'\// {gsub(/'"$i"'\//, ""); print $3, $1}' $f | sort)"
done
tput civis
if ! ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" \
'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \
'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"; then
return 1
fi
while true; do
tput civis
ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" \
'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \
'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"
if ! SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 17)) ${SUBZONES[$ZONE]})"; then
return 1
fi
[[ $ZONE ]] || { err=1; break; }
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $SHL ${subz[$ZONE]})"
yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE?\n" || select_timezone
}
[[ $SUBZONE ]] || { err=1; break; }
yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE\n" && break
done
return $err
}
select_sessions()
{
@ -472,13 +467,13 @@ select_sessions()
[[ $INSTALL_WMS ]] || return 1
WM_NUM=$(awk '{print NF}' <<< "$INSTALL_WMS")
WM_PACKAGES="${INSTALL_WMS/dwm/}" # remove dwm from package list
WM_PACKAGES="${WM_PACKAGES// / }" # remove double spaces
WM_PACKAGES="${WM_PACKAGES# }" # remove leading space
WM_PKGS="${INSTALL_WMS/dwm/}" # remove dwm from package list
WM_PKGS="${WM_PKGS// / }" # remove double spaces
WM_PKGS="${WM_PKGS# }" # remove leading space
for wm in $INSTALL_WMS; do
LOGIN_CHOICES+="$wm - "
[[ ${WM_EXT[$wm]} && $WM_PACKAGES != *"${WM_EXT[$wm]}"* ]] && WM_PACKAGES+=" ${WM_EXT[$wm]}"
[[ ${WM_EXT[$wm]} && $WM_PKGS != *"${WM_EXT[$wm]}"* ]] && WM_PKGS+=" ${WM_EXT[$wm]}"
done
select_login || return 1
@ -496,8 +491,8 @@ select_sessions()
fi
# add unique wm packages to main package list
for i in $WM_PACKAGES; do
[[ $PACKAGES == *$i* ]] || PACKAGES+=" ${WM_PACKAGES# }"
for i in $WM_PKGS; do
[[ $PACKAGES == *$i* ]] || PACKAGES+=" ${WM_PKGS# }"
done
return 0
@ -512,12 +507,12 @@ select_login()
if [[ $LOGIN_TYPE == "" ]]; then
return 1
elif [[ $LOGIN_TYPE == 'lightdm' ]]; then
WM_PACKAGES+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
WM_PKGS+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf"
else
PACKAGES="${PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}"
WM_PACKAGES="${WM_PACKAGES// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}"
WM_PACKAGES+=" xorg-xinit"
WM_PKGS="${WM_PKGS// lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice/}"
WM_PKGS+=" xorg-xinit"
EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
fi
}
@ -568,38 +563,40 @@ select_mirrorcmd()
edit_configs()
{
tput civis
local choice
choice=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_EditTitle " --menu "$_EditBody" 0 0 0 \
"keyboard" "${EDIT_FILES[keyboard]}" \
"console" "${EDIT_FILES[console]}" \
"locale" "${EDIT_FILES[locale]}" \
"hostname" "${EDIT_FILES[hostname]}" \
"sudoers" "${EDIT_FILES[sudoers]}" \
"mkinitcpio" "${EDIT_FILES[mkinitcpio]}" \
"fstab" "${EDIT_FILES[fstab]}" \
"crypttab" "${EDIT_FILES[crypttab]}" \
"bootloader" "${EDIT_FILES[bootloader]}" \
"pacman" "${EDIT_FILES[pacman]}" \
"login" "${EDIT_FILES[login]}" \
"Finished" "Unmount partitions, exit the installer, and reboot")
local choice i=0
if [[ $choice == "" || $choice == "Finished" ]]; then
[[ $DEBUG == true && -r $DBG ]] && vim $DBG
# when die() is passed 127 it will call: systemctl -i reboot
die 127
else
local exists=""
for f in $(printf "%s" "${EDIT_FILES[$choice]}"); do
[[ -e ${MNT}$f ]] && exists+=" ${MNT}$f"
done
if [[ $exists ]]; then
vim -O $exists
while true; do
choice=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
--title " $_EditTitle " --menu "$_EditBody" 0 0 0 \
"finished" "exit the installer and reboot" \
"keyboard" "${EDIT_FILES[keyboard]}" \
"console" "${EDIT_FILES[console]}" \
"locale" "${EDIT_FILES[locale]}" \
"hostname" "${EDIT_FILES[hostname]}" \
"sudoers" "${EDIT_FILES[sudoers]}" \
"mkinitcpio" "${EDIT_FILES[mkinitcpio]}" \
"fstab" "${EDIT_FILES[fstab]}" \
"crypttab" "${EDIT_FILES[crypttab]}" \
"bootloader" "${EDIT_FILES[bootloader]}" \
"pacman" "${EDIT_FILES[pacman]}" \
"login" "${EDIT_FILES[login]}")
if [[ $choice == "" || $choice == "finished" ]]; then
[[ $DEBUG == true && -r $DBG ]] && vim $DBG
# when die() is passed 127 it will call: systemctl -i reboot
die 127
else
msgbox "$_ErrTitle" "$_NoFileErr"
local exists=""
for f in $(printf "%s" "${EDIT_FILES[$choice]}"); do
[[ -e ${MNT}$f ]] && exists+=" ${MNT}$f"
done
if [[ $exists ]]; then
vim -O $exists
else
msgbox "$_ErrTitle" "$_NoFileErr"
fi
fi
fi
edit_configs
done
}
###############################################################################
@ -831,7 +828,7 @@ pkg_extra()
###############################################################################
# partition menus
partition_menu()
part_menu()
{
local device choice
@ -843,7 +840,7 @@ partition_menu()
fi
tput civis
if [[ $DISPLAY ]] && hash gparted >/dev/null 2>&1; then
if [[ $DISPLAY && $TERM != 'linux' ]] && hash gparted >/dev/null 2>&1; then
choice="$(menubox "$_PartTitle" "$_PartBody" \
"$_PartShowTree" "Shows output from the lsblk command" \
"$_PartAuto" "Full device automatic partitioning" \
@ -868,13 +865,11 @@ partition_menu()
if [[ $choice == "$_Done" || $choice == "" ]]; then
return 0
elif [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then
clear; tput cnorm; $choice "$device"; partition_menu "$device"
clear; tput cnorm; $choice "$device"
elif [[ $choice == "$_PartShowTree" ]]; then
msgbox "$_PartTitle" "\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT "$device")\n\n"
partition_menu "$device"
elif [[ $choice == "$_PartWipe" ]]; then
yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody" && wipe -Ifrev $device
partition_menu "$device"
else
local root_size msg ret table boot_fs
root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 {
@ -892,20 +887,22 @@ partition_menu()
fi
if yesno "$_PrepParts" "$_PartBody1 $device $msg ($root_size)$_PartBody3"; then
auto_partition "$device" "$table" "$boot_fs" "$root_size" || return 1
else
partition_menu "$device"
if auto_partition "$device" "$table" "$boot_fs" "$root_size"; then
return 0
else
return 1
fi
fi
fi
return 0
part_menu "$device"
}
format_as()
{
infobox "$_FSTitle" "\nRunning: ${FS_CMDS[$2]} $1\n" 1
${FS_CMDS[$2]} "$1" >/dev/null 2>$ERR
errshow "${FS_CMDS[$2]} $1"
errshow "${FS_CMDS[$2]} $1" && FORMATTED+=" $part"
}
enable_swap()
@ -940,7 +937,6 @@ device_tree()
select_device()
{
local dev msg
[[ $1 == 'boot' ]] && msg="$_DevSelTitle for bootloader\n" || umount_dir $MNT
if [[ $DEV_COUNT -eq 1 && $SYS_DEVS ]]; then
@ -962,7 +958,6 @@ select_device()
confirm_mount()
{
local part="$1" mount="$2"
[[ $mount == "$MNT" ]] && local m="/ (root)" || local m="${mount#$MNT}"
if [[ $(mount) == *"$mount"* ]]; then
infobox "$_MntTitle" "$_MntSucc\nPartition: $part\nMountpoint: $m\n" 1
@ -1056,11 +1051,9 @@ auto_partition()
infobox "$_PrepParts" "\nCreating a $size ext4 root partition.\n" 0
parted -s $device mkpart primary ext4 513MiB 100% >/dev/null 2>&1
sleep 0.5
AUTO_ROOT_PART="$(lsblk -lno NAME,TYPE $device | awk 'NR == 3 {print "/dev/"$1}')"
mkfs.ext4 -q $AUTO_ROOT_PART >/dev/null 2>&1
tput civis
sleep 0.5
msgbox "$_PrepParts" "\nAuto partitioning complete.\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE $device)\n"
@ -1079,7 +1072,6 @@ mount_partition()
else
mount "$part" "$mountp" 2>$ERR
fi
confirm_mount $part "$mountp" || return 1
check_cryptlvm "$part"
@ -1088,8 +1080,7 @@ mount_partition()
find_partitions()
{
local str="$1"
local err=''
local str="$1" err=''
# string of partitions as /TYPE/PART SIZE
if [[ $IGNORE_DEV != "" ]]; then
@ -1144,9 +1135,8 @@ setup_boot_device()
###############################################################################
# mounting menus
mounting_menu()
mount_menu()
{
# prepare partition list PARTS for dialog
lvm_detect
umount_dir $MNT
find_partitions 'part|lvm|crypt' || { SEL=2; return 1; }
@ -1224,6 +1214,7 @@ select_mount_opts()
while true; do
MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $title " --checklist "$_MntBody" 0 0 0 $opts)"
if [[ $MNT_OPTS ]]; then
MNT_OPTS="$(sed 's/ /,/g; $s/,$//' <<< "$MNT_OPTS" )"
yesno "$title" "$_MntConfBody $MNT_OPTS\n" && break
@ -1239,15 +1230,14 @@ select_filesystem()
{
local part="$1" fs="" cur_fs="" err=0
cur_fs="$(lsblk -lno FSTYPE "$part" 2>/dev/null)"
local msg="\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-none}\nDefault: ext4"
[[ $part == $ROOT_PART && $ROOT_PART == $AUTO_ROOT_PART && $LUKS == "" && $LVM == "" ]] && return 0
[[ $part == "$ROOT_PART" && $ROOT_PART == "$AUTO_ROOT_PART" && ! $LUKS && ! $LVM ]] && return 0
while true; do
local msg="\nSelect which filesystem to use for: $part\n\nCurrent: ${cur_fs:-none}\nDefault: ext4"
tput civis
if [[ $cur_fs && $part != "$ROOT_PART" ]]; then
if [[ $cur_fs && ( $part != "$ROOT_PART" || $FORMATTED == *"$part"* ) ]]; then
fs="$(menubox "$_FSTitle: $part" "$msg" \
"$_Skip" "-" \
"$_Skip" "Do not format this partition" \
"ext4" "${FS_CMDS[ext4]}" \
"ext3" "${FS_CMDS[ext3]}" \
"ext2" "${FS_CMDS[ext2]}" \
@ -1261,6 +1251,7 @@ select_filesystem()
[[ $fs == "$_Skip" ]] && break
else
local msg="\nSelect which filesystem to use for: $part\n\nDefault: ext4"
fs="$(menubox "$_FSTitle: $part" "$msg" \
"ext4" "${FS_CMDS[ext4]}" \
"ext3" "${FS_CMDS[ext3]}" \
@ -1273,12 +1264,9 @@ select_filesystem()
"reiserfs" "${FS_CMDS[reiserfs]}")"
fi
[[ $fs ]] || { err=1; break; }
yesno "$_FSTitle" "\nFormat $part as $fs?\n" && break
done
(( err == 0 )) || return $err
[[ $fs == "$_Skip" ]] || format_as "$part" "$fs"
}
@ -1288,18 +1276,16 @@ select_efi_partition()
tput civis
if (( COUNT == 1 )); then
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_PrepMount" "$_OnlyOne for EFI: $BOOT_PART\n" 1
elif [[ $BOOT_PART == "$AUTO_BOOT_PART" ]]; then
elif [[ $AUTO_BOOT_PART ]]; then
BOOT_PART="$AUTO_BOOT_PART"
return 0 # were done here
else
BOOT_PART="$(menubox "$_PrepMount" "$_SelUefiBody" $PARTS)"
fi
[[ $BOOT_PART ]] || return 1
if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormUefiBody $BOOT_PART $_FormUefiBody2"
local msg="$_FormUefiBody $BOOT_PART $_FormBootBody"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format_as "$BOOT_PART" "vfat"
sleep 1
@ -1315,11 +1301,11 @@ select_efi_partition()
select_boot_partition()
{
tput civis
if [[ $AUTO_BOOT_PART && $AUTO_BOOT_PART == "$BOOT_PART" ]]; then
if [[ $AUTO_BOOT_PART && ! $LVM ]]; then
BOOT_PART="$AUTO_BOOT_PART"
return 0 # were done here
elif [[ $LUKS && ! $LVM ]]; then
BOOT_PART="$(menubox "$_PrepMount" "\nSelect the boot partition (/boot), this is required for LUKS." $PARTS)"
BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosLuksBody" $PARTS)"
[[ $BOOT_PART ]] || return 1
else
BOOT_PART="$(menubox "$_PrepMount" "$_SelBiosBody" "$_Skip" "-" $PARTS)"
@ -1327,7 +1313,7 @@ select_boot_partition()
fi
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormBiosBody $BOOT_PART $_FormBiosBody2"
local msg="$_FormBiosBody $BOOT_PART $_FormBootBody"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format_as "$BOOT_PART" "ext4"
sleep 1
@ -1344,7 +1330,6 @@ select_root_partition()
tput civis
if (( COUNT == 1 )); then
ROOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_PrepMount" "$_OnlyOne for root (/): $ROOT_PART\n" 1
elif ! ROOT_PART="$(menubox "$_PrepMount" "$_SelRootBody" $PARTS)"; then
return 1
fi
@ -1360,7 +1345,6 @@ select_extra_partitions()
while (( COUNT > 0 )); do
tput civis
part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the main menu" $PARTS)"
if [[ $part == "$_Done" || $part == "" ]]; then
break
elif select_filesystem "$part" && select_mountpoint && mount_partition "$part" "$EXMNT"; then
@ -1395,7 +1379,7 @@ install()
login_manager
printf "Setting ownership of /home/$NEWUSER\n"
chrun "chown -Rf $NEWUSER:users /home/$NEWUSER"
sleep 3
sleep 1
edit_configs
}
@ -1677,10 +1661,7 @@ package_operations()
inpkg+=" linux-hardened"; rmpkg+=" linux"
fi
if [[ $MYSHELL == '/usr/bin/zsh' ]]; then
inpkg+=" zsh-completions zsh-history-substring-search"
fi
[[ $MYSHELL == '/usr/bin/zsh' ]] && inpkg+=" zsh-completions zsh-history-substring-search"
[[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm) ]] && inpkg+=" $WM_BASE_PKGS"
[[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey"
@ -1703,14 +1684,14 @@ suckless_install()
if chrun "git clone https://bitbucket.org/natemaia/$i /home/$NEWUSER/suckless/$i"; then
chrun "cd /home/$NEWUSER/suckless/$i; rm -f config.h; make clean install; make clean"
else
printf "Failed to clone $i repo\n"
printf "failed to clone $i repo\n"
fi
done
if [[ -d $MNT/home/$NEWUSER/suckless/dwm && -x $MNT/usr/bin/dwm ]]; then
printf "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h\n"
printf "You can then recompile it with 'sudo make clean install'\n"
sleep 3
sleep 2
fi
}
@ -1733,12 +1714,10 @@ setup_boot()
fi
[[ $BOOTLDR ]] || return 1
if [[ $BOOT_PART != "" ]]; then
mount_partition "$BOOT_PART" "/boot" && SEP_BOOT=true || return 1
setup_boot_device
fi
setup_${BOOTLDR} || return 1
}
@ -1784,19 +1763,15 @@ setup_systemd-boot()
prerun_grub()
{
local cfg="$MNT/etc/default/grub"
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g;
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub
if [[ $LUKS_DEV ]]; then
sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g;
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub
fi
if [[ $SYS == 'BIOS' && $LVM && $SEP_BOOT == false ]]; then
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $MNT/etc/default/grub
fi
# needed for grub-probe module to work properly in the chroot
# once the grub install is done these will be umounted and removed
mkdir -p /run/lvm
mkdir -p /run/udev
mkdir -p $MNT/hostrun/lvm
@ -1809,7 +1784,6 @@ prerun_grub()
prerun_systemd-boot()
{
# create the boot entry configs
mkdir -p ${MNT}/boot/loader/entries
cat > ${MNT}/boot/loader/loader.conf << EOF
default $DIST
@ -1828,7 +1802,6 @@ linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/${UCODE}.img
initrd /initramfs-$KERNEL-fallback.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF
# add pacman hook to update the bootloader when systemd receives an update
mkdir -p $MNT/etc/pacman.d/hooks
cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook << EOF
[Trigger]
@ -1841,7 +1814,6 @@ Description = Updating systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update
EOF
# systemd-boot requires this before running bootctl
systemd-machine-id-setup --root="$MNT"
return 0
}
@ -1858,17 +1830,16 @@ MENU BACKGROUND splash.png
TIMEOUT 50
DEFAULT $DIST
# Refer to https://www.syslinux.org/wiki/index.php/Comboot/menu.c32
MENU WIDTH 78
MENU MARGIN 4
MENU ROWS 5
MENU ROWS 4
MENU VSHIFT 10
MENU TIMEOUTROW 13
MENU TABMSGROW 14
MENU CMDLINEROW 14
MENU HELPMSGROW 16
MENU HELPMSGENDROW 29
# Refer to https://www.syslinux.org/wiki/index.php/Comboot/menu.c32
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
@ -1879,7 +1850,6 @@ MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
LABEL $DIST
MENU LABEL $DIST Linux
LINUX ../vmlinuz-$KERNEL
@ -1892,7 +1862,6 @@ LINUX ../vmlinuz-$KERNEL
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
INITRD $([[ $UCODE ]] && printf "%s" "../${UCODE}.img,")../initramfs-$KERNEL-fallback.img
# some examples for chainloading other bootloaders
#LABEL grub2
@ -2049,55 +2018,56 @@ get_lv_size()
lvm_volume_name()
{
local msg="$1"
local msg="$1" default="mainvolume" name="" err=0
(( VOL_COUNT > 1 )) && default="extravolume$VOL_COUNT"
local default="volmain"
(( VOL_COUNT > 1 )) && default="volextra"
while true; do
tput cnorm
name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$msg" "$default" nolimit)"
[[ $name ]] || { err=1; break; }
if [[ ${name:0:1} == "/" || ${#name} -eq 0 || $name =~ \ |\' ]] || grep -q "$name" <<< "$(lsblk)"; then
msgbox "$_ErrTitle" "$_LvmLvNameErrBody"
else
VOLUME_NAME="$name"
break
fi
done
tput cnorm
local name
if ! name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$msg" "$default" nolimit)"; then
return 1
fi
if [[ ${name:0:1} == "/" || ${#name} -eq 0 || $name =~ \ |\' ]] || grep -q "$name" <<< "$(lsblk)"; then
msgbox "$_ErrTitle" "$_LvmLvNameErrBody"
lvm_volume_name "$msg" || return 1
fi
VOLUME_NAME="$name"
return 0
return $err
}
lvm_group_name()
{
tput cnorm
local group
if ! group="$(getinput "$_LvmCreateVG" "$_LvmNameVgBody" "VolGroup" nolimit)"; then
return 1
fi
local group="" err=0
if [[ ${group:0:1} == "/" || ${#group} -eq 0 || $group =~ \ |\' ]] || grep -q "$group" <<< "$(lsblk)"; then
msgbox "$_ErrTitle" "$_LvmNameVgErr"
lvm_group_name || return 1
fi
while true; do
tput cnorm
group="$(getinput "$_LvmCreateVG" "$_LvmNameVgBody" "VolGroup" nolimit)"
[[ $group ]] || { err=1; break; }
if [[ ${group:0:1} == "/" || ${#group} -eq 0 || $group =~ \ |\' ]] || grep -q "$group" <<< "$(lsblk)"; then
msgbox "$_ErrTitle" "$_LvmNameVgErr"
else
VOLUME_GROUP="$group"
break
fi
done
VOLUME_GROUP="$group"
return 0
return $err
}
lvm_extra_lvs()
{
local err=0
while (( VOL_COUNT > 1 )); do
lvm_volume_name "$_LvmLvNameBody1" || { break; return 1; }
get_lv_size || { break; return 1; }
lvm_volume_name "$_LvmLvNameBody1" && get_lv_size || { err=1; break; }
lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR
errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME"
errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME" || { err=1; break; }
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "\n$_Done Logical Volume (LV) $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2.\n"
(( VOL_COUNT-- ))
done
return 0
return $err
}
lvm_volumes()
@ -2134,7 +2104,7 @@ lvm_mkgroup()
done
vgcreate -f "$VOLUME_GROUP" "${LVM_PARTS[@]}" >/dev/null 2>$ERR
errshow "vgcreate -f $VOLUME_GROUP ${LVM_PARTS[*]}"
errshow "vgcreate -f $VOLUME_GROUP ${LVM_PARTS[*]}" || return 1
GROUP_SIZE=$(vgdisplay "$VOLUME_GROUP" | awk '/VG Size/ {
gsub(/[^0-9.]/, "")
@ -2165,7 +2135,7 @@ lvm_create()
lvm_extra_lvs || return 1
lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VGROUP_MB}MB)" || return 1
lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR
errshow "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME"
errshow "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME" || return 1
LVM='logical volume'; tput civis; sleep 0.5
local msg="\n$_Done $_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2.\n"
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n"
@ -2176,7 +2146,6 @@ lvm_del_vg()
if lvm_show_vg && yesno "$_LvmDelVG" "$_LvmDelQ"; then
vgremove -f "$DEL_VG" >/dev/null 2>&1
fi
return 0
}
lvm_del_all()
@ -2197,7 +2166,6 @@ lvm_del_all()
done
LVM=''
fi
return 0
}
###############################################################################
@ -2215,9 +2183,9 @@ luks_menu()
"$_Back" "Return to the main menu")"
case $choice in
"$_LuksEncrypt") luks_default || return 1 ;;
"$_LuksEncrypt") luks_basic || return 1 ;;
"$_LuksOpen") luks_open || return 1 ;;
"$_LuksEncryptAdv") luks_keycmd || return 1 ;;
"$_LuksEncryptAdv") luks_advanced || return 1 ;;
esac
return 0
@ -2225,7 +2193,6 @@ luks_menu()
luks_open()
{
LUKS_PART=""
modprobe -a dm-mod dm_crypt
umount_dir $MNT
find_partitions 'part|crypt|lvm' || return 1
@ -2233,18 +2200,16 @@ luks_open()
if (( COUNT == 1 )); then
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_LuksOpen" "${_OnlyOne}: $LUKS_PART\n" 1
elif ! LUKS_PART="$(menubox "$_LuksOpen" "$_LuksMenuBody" $PARTS)" || ! [[ $LUKS_PART ]]; then
return 1
else
LUKS_PART="$(menubox "$_LuksOpen" "$_LuksMenuBody" $PARTS)"
fi
[[ $LUKS_PART ]] || return 1
luks_pass "$_LuksOpen" || return 1
infobox "$_LuksOpen" "$_LuksOpenWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup open --type luks $LUKS_PART $LUKS_NAME"
LUKS='encrypted'
luks_show
errshow "cryptsetup open --type luks $LUKS_PART $LUKS_NAME" || return 1
LUKS='encrypted'; luks_show
return 0
}
@ -2300,7 +2265,6 @@ luks_pass()
luks_setup()
{
LUKS_PART=""
modprobe -a dm-mod dm_crypt
umount_dir $MNT
find_partitions 'part|lvm' || return 1
@ -2308,42 +2272,38 @@ luks_setup()
if (( COUNT == 1 )); then
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_LuksEncrypt" "${_OnlyOne}: $LUKS_PART\n" 1
elif ! LUKS_PART="$(menubox "$_LuksEncrypt" "$_LuksEncryptBody" $PARTS)"; then
return 1
elif ! luks_pass "$_LuksEncrypt"; then
return 1
else
LUKS_PART="$(menubox "$_LuksEncrypt" "$_LuksEncryptBody" $PARTS)"
fi
return 0
[[ $LUKS_PART ]] || return 1
luks_pass "$_LuksEncrypt"
}
luks_default()
luks_basic()
{
luks_setup || return 1
infobox "$_LuksEncrypt" "$_LuksCreateWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
cryptsetup -q luksFormat $LUKS_PART <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup -q luksFormat $LUKS_PART"
errshow "cryptsetup -q luksFormat $LUKS_PART" || return 1
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup open $LUKS_PART $LUKS_NAME"
LUKS='encrypted'
luks_show
errshow "cryptsetup open $LUKS_PART $LUKS_NAME" || return 1
LUKS='encrypted'; luks_show
return 0
}
luks_keycmd()
luks_advanced()
{
if luks_setup; then
tput cnorm
local cipher
if ! cipher="$(getinput "$_PrepLUKS" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64" nolimit)"; then
return 1
fi
cipher="$(getinput "$_PrepLUKS" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64" nolimit)"
[[ $cipher ]] || return 1
infobox "$_LuksEncryptAdv" "$_LuksCreateWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
cryptsetup -q $cipher luksFormat $LUKS_PART <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup -q $cipher luksFormat $LUKS_PART"
errshow "cryptsetup -q $cipher luksFormat $LUKS_PART" || return 1
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup open $LUKS_PART $LUKS_NAME"
errshow "cryptsetup open $LUKS_PART $LUKS_NAME" || return 1
luks_show
return 0
fi
@ -2378,7 +2338,7 @@ luks_keyfile()
ofn()
{
[[ $USER_PKGS == *$1* ]] && printf "on" || printf "off"
[[ $USER_PKGS == *"$1"* ]] && printf "on" || printf "off"
}
chrun()
@ -2410,16 +2370,15 @@ is_ssd()
die()
{
(( $# >= 1 )) && local exitcode=$1 || local exitcode=0
(( $# >= 1 )) && exitcode=$1 || exitcode=0
trap - INT
tput cnorm
if [[ -d $MNT ]] && command cd /; then
umount_dir $MNT
if (( exitcode == 127 )); then
umount -l /run/archiso/bootmnt
sleep 0.5
systemctl -i reboot
umount -l /run/archiso/bootmnt; sleep 0.5; systemctl -i reboot
fi
fi
@ -2521,7 +2480,7 @@ load_bcm()
chk_connect()
{
if [[ $CHECKED_NET == true ]]; then
infobox "Network Connect" "\nVerifying connection\n" 1
infobox "Network Connect" "\nVerifying network connection\n" 1
else
infobox "Network Connect" "\nChecking connection to https://www.archlinux.org\n" 1
CHECKED_NET=true
@ -2557,7 +2516,7 @@ system_checks()
die 1
fi
grep -q 'BCM4352' <<< "$(lspci -vnn -d 14e4:)" && load_bcm
net_connect || { infobox "$_ErrTitle" "$_NoNetwork\n$_Exit" 3; die 1; }
net_connect || { infobox "$_ErrTitle" "$_NoNetwork\n$_Exit"; die 1; }
}
prechecks()
@ -2569,15 +2528,15 @@ prechecks()
elif [[ $1 -ge 2 && $CONFIG_DONE != true ]]; then
infobox "$_ErrTitle" "$_ErrNoConfig"; SEL=6; return 1
fi
return 0
}
errshow()
{
local last_exit_code=$?
last_exit_code=$?
(( last_exit_code == 0 )) && return 0
local err
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
local err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
if [[ $err ]]; then
msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the following message: $err"
@ -2589,6 +2548,8 @@ errshow()
[[ -e $DBG && $TERM == 'linux' ]] && less $DBG
die 1
fi
return 1
}
debug()