Fix: error in package_operation() where two package names wouldn't be space separated

This commit is contained in:
natemaia 2019-01-18 23:18:58 -08:00
parent b20102f5bd
commit 1e6f7a1438
2 changed files with 205 additions and 193 deletions

View File

@ -49,8 +49,8 @@ _CloseInstBody="\nUnmount partitions (if any) and exit the installer?\n"
# timezone # timezone
_TimeZTitle="Timezone" _TimeZTitle="Timezone"
_TimeZQ="\nConfirm time zone:" _TimeZQ="\nConfirm time zone:"
_TimeSubZBody="\nSelect the nearest city to you or one with the same time zone.\n\nTIP: Pressing the first letter of the city name repeatedly will navigate between entries beggining with that letter."
_TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below" _TimeZBody="\nThe time zone is used to set the system clock.\n\nSelect your country or continent from the list below"
_TimeSubZBody="\nSelect the nearest city to you or one with the same time zone.\n\nTIP: Pressing the first letter of the city name repeatedly will navigate between entries beggining with that letter."
# bootloader # bootloader
_MntBootBody="\nSelect which bootloader to use." _MntBootBody="\nSelect which bootloader to use."
@ -101,7 +101,7 @@ _MntFail="\nMount Failed!\n"
_MntSucc="\nMount Succeeded!\n" _MntSucc="\nMount Succeeded!\n"
_MntConfBody="\nConfirm mount options:" _MntConfBody="\nConfirm mount options:"
_MntBody="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount." _MntBody="\nUse [Space] to toggle mount options from below, press [Enter] when done to confirm selection.\n\nNot selecting any and confirming will run an automatic mount."
_WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nDuring mounting, partitions can be mounted without formatting by selecting '$_Skip'.\nThis can be useful for data partitions or partitions you've already formatted.\n\nThe one exception is the root (/) partition, it needs to be formatted before install to ensure the system stability.\n" _WarnMount="\nIMPORTANT: Please choose carefully during mounting and formatting.\n\nDuring mounting, partitions can be mounted without formatting by selecting '$_Skip', useful for extra or already formatted partitions.\n\nThe exception to this is the root (/) partition, it needs to be formatted before install to ensure system stability.\n"
# Select Device # Select Device
_DevSelTitle="Device Selection" _DevSelTitle="Device Selection"
@ -138,7 +138,7 @@ _InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?
# File System # File System
_FSTitle="Choose Filesystem" _FSTitle="Choose Filesystem"
_SelRootBody="\nSelect root (/) partition.\n\nThis is the partition where $DIST will be installed." _SelRootBody="\nSelect the system root (/) partition.\n\nThis is where $DIST will be installed."
_SelBiosBody="\nDo you want to use a separate boot partition? (required for LUKS)\n\nThis partition is where the bootloader will be installed.\n" _SelBiosBody="\nDo you want to use a separate boot partition? (required for LUKS)\n\nThis partition is where the bootloader will be installed.\n"
_SelSwpNone="None" _SelSwpNone="None"
@ -146,7 +146,7 @@ _SelSwpFile="Swapfile"
_SelSwpSetup="Swap Setup" _SelSwpSetup="Swap Setup"
_SelSwpBody="\nSelect whether to use a swap partition, swapfile, or none." _SelSwpBody="\nSelect whether to use a swap partition, swapfile, or none."
_SelSwpErr="Swap Setup Error: Must be 1(M|G) or greater, and can only contain whole numbers\n\nSize Entered:" _SelSwpErr="Swap Setup Error: Must be 1(M|G) or greater, and can only contain whole numbers\n\nSize Entered:"
_SelSwpSize="\nEnter the size to use for swap in MB or GB.\n\nFor ease of use and as an example the size has been filled in to the size of your system memory (RAM).\n\nMust be greater than 1, end in either M or G, and contain only whole numbers." _SelSwpSize="\n\n\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\neg. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example the size has been filled in to the size of your system memory (RAM).\n\nMust be greater than 1, end in either M or G, and contain only whole numbers."
_SelUefiBody="\nSelect the system EFI boot partition.\n\nThis is a required partition for booting UEFI systems. It's usually the first partition on the drive, less than 512M, and will be formatted as vfat/fat32 if not already." _SelUefiBody="\nSelect the system EFI boot partition.\n\nThis is a required partition for booting UEFI systems. It's usually the first partition on the drive, less than 512M, and will be formatted as vfat/fat32 if not already."
_FormUefiBody="\nIMPORTANT: The EFI partition" _FormUefiBody="\nIMPORTANT: The EFI partition"
@ -159,12 +159,12 @@ _LuksMenuBody="\nDevices and volumes encrypted using dm_crypt cannot be accessed
_LuksMenuBody2="\n\nA seperate boot partition without encryption or logical volume management (LVM - unless using BIOS Grub) is required." _LuksMenuBody2="\n\nA seperate boot partition without encryption or logical volume management (LVM - unless using BIOS Grub) is required."
_LuksMenuBody3="\n\nAutomatic uses default encryption settings, and is recommended for beginners, otherwise cypher and key size parameters may be entered manually." _LuksMenuBody3="\n\nAutomatic uses default encryption settings, and is recommended for beginners, otherwise cypher and key size parameters may be entered manually."
_LuksOpen="Open Encrypted Partition" _LuksOpen="Open Encrypted Partition"
_LuksOpenBody="Enter a name and password for the encrypted device.\n\nIt is not necessary to prefix it with /dev/mapper/.\n\nAn example name has been provided." _LuksOpenBody="Enter a name and password for the encrypted device.\n\nIt is not necessary to prefix it with /dev/mapper/\n\nAn example name has been provided."
_LuksEncrypt="Automatic LUKS Encryption" _LuksEncrypt="Automatic LUKS Encryption"
_LuksEncryptAdv="Define Key-Size and Cypher" _LuksEncryptAdv="Define Key-Size and Cypher"
_LuksEncryptBody="\nSelect the partition you want to encrypt." _LuksEncryptBody="\nSelect the partition you want to encrypt."
_LuksEncryptSucc="\nDone! encrypted partition opened and ready for mounting.\n" _LuksEncryptSucc="\nDone! encrypted partition opened and ready for mounting.\n"
_LuksPartErrBody="\nA minimum of two partitions are required for encryption:\n\n1. Root (/) - standard or LVM.\n\n2. Boot (/boot or /boot/efi) - standard (except for LVM on BIOS systems)." _LuksPartErrBody="\nA minimum of two partitions are required for encryption:\n\n1. root (/) - standard or LVM.\n\n2. boot (/boot or /boot/efi) - standard (except for LVM on BIOS systems)."
_LuksCreateWaitBody="\nCreating encrypted partition:" _LuksCreateWaitBody="\nCreating encrypted partition:"
_LuksOpenWaitBody="\nOpening encrypted partition:" _LuksOpenWaitBody="\nOpening encrypted partition:"
_LuksWaitBody2="\n\nDevice or volume used:" _LuksWaitBody2="\n\nDevice or volume used:"
@ -188,7 +188,7 @@ _LvmLvNumBody2="\nThe last (or only) logical volume will automatically use all r
_LvmLvNameBody1="Enter the name of the logical volume (LV) to create.\n\nThis is like setting a name or label for a partition.\n" _LvmLvNameBody1="Enter the name of the logical volume (LV) to create.\n\nThis is like setting a name or label for a partition.\n"
_LvmLvNameBody2="\nNOTE: This logical volume will use up all remaining space in the volume group" _LvmLvNameBody2="\nNOTE: This logical volume will use up all remaining space in the volume group"
_LvmLvSizeBody1="remaining" _LvmLvSizeBody1="remaining"
_LvmLvSizeBody2="\n\nEnter the size of the logical volume (LV) in megabytes (M) or gigabytes (G). For example, 100M will create a 100 megabyte LV. 10G will create a 10 Gigabyte LV.\n" _LvmLvSizeBody2="\n\nEnter the size of the logical volume (LV) in megabytes (M) or gigabytes (G). For example, 100M will create a 100 megabyte LV. 10G will create a 10 gigabyte LV.\n"
_LvmCompBody="\nDone! all logical volumes have been created for the volume group.\n\nDo you want to view the device tree for the new LVM scheme?\n" _LvmCompBody="\nDone! all logical volumes have been created for the volume group.\n\nDo you want to view the device tree for the new LVM scheme?\n"
_LvmDelQ="\nConfirm deletion of volume group(s) and logical volume(s).\n\nDeleting a volume group, will delete all logical volumes within as well." _LvmDelQ="\nConfirm deletion of volume group(s) and logical volume(s).\n\nDeleting a volume group, will delete all logical volumes within as well."
_LvmSelVGBody="Select volume group to delete.\n\nAll logical volumes within will also be deleted." _LvmSelVGBody="Select volume group to delete.\n\nAll logical volumes within will also be deleted."

View File

@ -5,13 +5,15 @@
# This program is free software, provided under the GNU GPL # This program is free software, provided under the GNU GPL
# Written by Nathaniel Maia for use in Archlabs # Written by Nathaniel Maia for use in Archlabs
# Some ideas and code has been taken from other installers # Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
VER="1.8.39" # version VER="1.8.42" # version
DIST="ArchLabs" # distributor DIST="ArchLabs" # distributor
MNT="/mnt" # install mountpoint MNT="/mnt" # install mountpoint
# set -n
# bulk default values { # bulk default values {
ROOT_PART="" # root partition ROOT_PART="" # root partition
@ -28,11 +30,11 @@ ROOT_PASS="" # root password
LOGIN_WM="" # default login session LOGIN_WM="" # default login session
LOGIN_TYPE="" # login manager can be lightdm or xinit LOGIN_TYPE="" # login manager can be lightdm or xinit
INSTALL_WMS="" # space separated list of chosen wm/de INSTALL_WMS="" # space separated list of chosen wm/de
KERNEL="" # kernel can be linux or linux-lts KERNEL="linux" # kernel can be linux or linux-lts
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_PACKAGES
USER_PKGS="" # packages selected by the user during install USER_PKGS="" # packages selected by the user during install
WM_PACKAGES="" # full list of packages added during wm/de choice WM_PACKAGES="" # full list of packages added during wm/de choice
MYSHELL="" # login shell for root and the primary user
UCODE="" # cpu manufacturer microcode filename (if any) UCODE="" # cpu manufacturer microcode filename (if any)
HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf
FONT="ter-i16n" # font used in the linux console FONT="ter-i16n" # font used in the linux console
@ -55,6 +57,9 @@ CONFIG_DONE=false # basic configuration is finished
BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352 BROADCOM_WL=false # fixes for broadcom cards eg. BCM4352
CHECKED_NET=false # have we checked the network connection already CHECKED_NET=false # have we checked the network connection already
AUTO_ROOT_PART="" # values from auto partition
AUTO_BOOT_PART=""
# sane baseline # sane baseline
BASE_PKGS="archlabs-scripts archlabs-skel-base archlabs-themes archlabs-dARK archlabs-icons archlabs-wallpapers " 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+="base-devel xorg xorg-drivers sudo git gvfs gtk3 gtk-engines gtk-engine-murrine pavucontrol tumbler "
@ -64,15 +69,12 @@ BASE_PKGS+="playerctl ffmpeg gstreamer libmad libmatroska gst-libav gst-plugins-
WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip exo " WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu xdg-user-dirs nitrogen polkit-gnome volumeicon xclip exo "
WM_BASE_PKGS+="xdotool compton gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect" WM_BASE_PKGS+="xdotool compton gnome-keyring dunst feh gsimplecal xfce4-power-manager xfce4-settings laptop-detect"
SEL=0 # currently selected menu item
ERR="/tmp/errlog" # error log used internally ERR="/tmp/errlog" # error log used internally
DBG="/tmp/debuglog" # debug log when passed -d DBG="/tmp/debuglog" # debug log when passed -d
RUN="/run/archiso/bootmnt/arch/boot" # path for live /boot RUN="/run/archiso/bootmnt/arch/boot" # path for live /boot
BT="$DIST Installer - v$VER" # backtitle used for dialogs BT="$DIST Installer - v$VER" # backtitle used for dialogs
VM="$(dmesg | grep -i "hypervisor")" # is the system a vm VM="$(dmesg | grep -i "hypervisor")" # is the system a vm
SEL=0 # currently selected menu item
AUTO_ROOT_PART="" # values from auto partition
AUTO_BOOT_PART=""
# } # }
@ -237,10 +239,10 @@ main()
case $SEL in case $SEL in
1) device_tree ;; 1) device_tree ;;
2) partition || (( SEL-- )) ;; 2) partition_menu || (( SEL-- )) ;;
3) luks_menu || (( SEL-- )) ;; 3) luks_menu || (( SEL-- )) ;;
4) lvm_menu || (( SEL-- )) ;; 4) lvm_menu || (( SEL-- )) ;;
5) mnt_menu || (( SEL-- )) ;; 5) mounting_menu || (( SEL-- )) ;;
6) prechecks 0 && { mkuser || (( SEL-- )); } ;; 6) prechecks 0 && { mkuser || (( SEL-- )); } ;;
7) prechecks 1 && { cfg_menu || (( SEL-- )); } ;; 7) prechecks 1 && { cfg_menu || (( SEL-- )); } ;;
8) prechecks 2 && { select_sessions || (( SEL-- )); } ;; 8) prechecks 2 && { select_sessions || (( SEL-- )); } ;;
@ -343,49 +345,49 @@ cfg_menu()
mkuser() mkuser()
{ {
tput cnorm local values="" user="" pass="" pass2="" rpass="" rpass2="" err=0
local values
if ! values="$(dialog --stdout --no-cancel --separator ';:~:;' \
--ok-label "Submit" --backtitle "$BT" --title " $_UserTitle " \
--insecure --mixedform "$_UserBody" 0 0 0 \
"$_Username" 1 1 "$NEWUSER" 1 $((${#_Username} + 2)) $COLUMNS 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1 \
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) $COLUMNS 0 2 \
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) $COLUMNS 0 1)"; then
return 1
fi
local user pass pass2 rpass rpass2 while true; do
user="$(awk -F';:~:;' '{print $1}' <<< "$values")" tput cnorm
pass="$(awk -F';:~:;' '{print $2}' <<< "$values")" values="$(dialog --stdout --no-cancel --separator ';:~:;' \
pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")" --ok-label "Submit" --backtitle "$BT" --title " $_UserTitle " \
rpass="$(awk -F';:~:;' '{print $5}' <<< "$values")" --insecure --mixedform "$_UserBody" 0 0 0 \
rpass2="$(awk -F';:~:;' '{print $6}' <<< "$values")" "$_Username" 1 1 "$user" 1 $((${#_Username} + 2)) $COLUMNS 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1 \
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) $COLUMNS 0 2 \
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) $COLUMNS 0 1)"
# both root passwords are empty, so use the user passwords instead err=$?
[[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; } (( err == 0 )) || break
# make sure a username was entered and that the passwords match user="$(awk -F';:~:;' '{print $1}' <<< "$values")"
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9] ]]; then pass="$(awk -F';:~:;' '{print $2}' <<< "$values")"
msgbox "$_UserErrTitle" "$_UserErrBody" pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")"
mkuser || return 1 rpass="$(awk -F';:~:;' '{print $5}' <<< "$values")"
elif [[ $pass == "" ]]; then rpass2="$(awk -F';:~:;' '{print $6}' <<< "$values")"
msgbox "$_ErrTitle" "$_UserPassEmpty\n$_TryAgain"
mkuser || return 1
elif [[ "$pass" != "$pass2" ]]; then
msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain"
mkuser || return 1
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
mkuser || return 1
fi
NEWUSER="$user" # root passwords empty, so use the user passwords
USER_PASS="$pass" [[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; }
ROOT_PASS="$rpass"
return 0 # make sure a username was entered and that the passwords match
if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9] ]]; then
msgbox "$_UserErrTitle" "$_UserErrBody"; user=""
elif [[ $pass == "" ]]; then
msgbox "$_ErrTitle" "$_UserPassEmpty\n$_TryAgain"
elif [[ "$pass" != "$pass2" ]]; then
msgbox "$_ErrTitle" "$_UserPassErr\n$_TryAgain"
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
else
NEWUSER="$user"
USER_PASS="$pass"
ROOT_PASS="$rpass"
break
fi
done
return $err
} }
select_keymap() select_keymap()
@ -447,16 +449,16 @@ select_timezone()
if ! ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" \ if ! ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" \
'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \ 'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \
'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"; then 'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"; then
return 1 return 1
fi fi
if ! SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \ if ! SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 17)) ${SUBZONES[$ZONE]})"; then --title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 17)) ${SUBZONES[$ZONE]})"; then
return 1 return 1
fi fi
yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE?\n" || select_timezone yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE?\n" || select_timezone
} }
select_sessions() select_sessions()
{ {
@ -613,7 +615,8 @@ edit_configs()
select_packages() select_packages()
{ {
local cur=0 local cur=0 b="" e="" f="" t="" m="" ml="" p="" v="" fn="" to="" s="" x=""
while true; do while true; do
(( cur < 13 )) && (( cur++ )) (( cur < 13 )) && (( cur++ ))
@ -638,25 +641,23 @@ select_packages()
[[ $cur && $cur -lt 13 ]] || break [[ $cur && $cur -lt 13 ]] || break
case $cur in case $cur in
1) BROWSE_PKGS="$(select_browsers)" ;; 1) b="$(pkg_browsers)" ;;
2) EDIT_PKGS="$(select_editors)" ;; 2) e="$(pkg_editors)" ;;
3) FM_PKGS="$(select_files)" ;; 3) f="$(pkg_files)" ;;
4) TERM_PKGS="$(select_terms)" ;; 4) t="$(pkg_terms)" ;;
5) MEDIA_PKGS="$(select_media)" ;; 5) m="$(pkg_media)" ;;
6) MAIL_PKGS="$(select_mail)" ;; 6) ml="$(pkg_mail)" ;;
7) PROF_PKGS="$(select_prof)" ;; 7) p="$(pkg_prof)" ;;
8) VIEW_PKGS="$(select_viewers)" ;; 8) v="$(pkg_viewers)" ;;
9) FNT_PKGS="$(select_fonts)" ;; 9) fn="$(pkg_fonts)" ;;
10) TOR_PKGS="$(select_torrent)" ;; 10) to="$(pkg_torrent)" ;;
11) SYS_PKGS="$(select_sys)" ;; 11) s="$(pkg_sys)" ;;
12) EX_PKGS=" $(select_extra)" ;; 12) x="$(pkg_extra)" ;;
esac esac
USER_PKGS="$BROWSE_PKGS $EDIT_PKGS $FM_PKGS $TERM_PKGS $MEDIA_PKGS $MAIL_PKGS "
USER_PKGS+="$PROF_PKGS $VIEW_PKGS $FNT_PKGS $TOR_PKGS $SYS_PKGS $EX_PKGS"
done
USER_PKGS="$BROWSE_PKGS $EDIT_PKGS $FM_PKGS $TERM_PKGS $MEDIA_PKGS $MAIL_PKGS " # add all to the user package list regardless of what was picked
USER_PKGS+="$PROF_PKGS $VIEW_PKGS $FNT_PKGS $TOR_PKGS $SYS_PKGS $EX_PKGS" USER_PKGS="$b $e $f $t $m $ml $p $v $fn $to $s $x"
done
for i in $USER_PKGS; do for i in $USER_PKGS; do
[[ ${PKG_EXT[$i]} && $USER_PKGS != *"${PKG_EXT[$i]}"* ]] && USER_PKGS="${USER_PKGS% } ${PKG_EXT[$i]}" [[ ${PKG_EXT[$i]} && $USER_PKGS != *"${PKG_EXT[$i]}"* ]] && USER_PKGS="${USER_PKGS% } ${PKG_EXT[$i]}"
@ -669,7 +670,7 @@ select_packages()
return 0 return 0
} }
select_browsers() pkg_browsers()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -682,7 +683,7 @@ select_browsers()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_editors() pkg_editors()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -694,7 +695,7 @@ select_editors()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_files() pkg_files()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -707,7 +708,7 @@ select_files()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_terms() pkg_terms()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -723,7 +724,7 @@ select_terms()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_media() pkg_media()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -741,7 +742,7 @@ select_media()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_mail() pkg_mail()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -756,7 +757,7 @@ select_mail()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_prof() pkg_prof()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -775,7 +776,7 @@ select_prof()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_fonts() pkg_fonts()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -788,7 +789,7 @@ select_fonts()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_viewers() pkg_viewers()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -800,7 +801,7 @@ select_viewers()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_torrent() pkg_torrent()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -812,7 +813,7 @@ select_torrent()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_sys() pkg_sys()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -822,7 +823,7 @@ select_sys()
printf "%s" "$pkgs" printf "%s" "$pkgs"
} }
select_extra() pkg_extra()
{ {
local pkgs="" local pkgs=""
pkgs="$(checkbox "$_Packages" "$_PackageBody" \ pkgs="$(checkbox "$_Packages" "$_PackageBody" \
@ -838,25 +839,18 @@ select_extra()
############################################################################### ###############################################################################
# partition menus # partition menus
format() partition_menu()
{ {
infobox "$_FSTitle" "\nRunning: ${FS_CMDS[$2]} $1\n" 1 local device choice
${FS_CMDS[$2]} "$1" >/dev/null 2>$ERR
errshow "${FS_CMDS[$2]} $1"
}
partition() if [[ $# -eq 1 ]]; then
{ device="$1"
local device else
if [[ $# -eq 0 ]]; then
select_device 'root' || return 1 select_device 'root' || return 1
device="$DEVICE" device="$DEVICE"
else
device="$1"
fi fi
tput civis tput civis
local choice
if [[ $DISPLAY ]] && hash gparted >/dev/null 2>&1; then if [[ $DISPLAY ]] && hash gparted >/dev/null 2>&1; then
choice="$(menubox "$_PartTitle" "$_PartBody" \ choice="$(menubox "$_PartTitle" "$_PartBody" \
"$_PartShowTree" "Shows output from the lsblk command" \ "$_PartShowTree" "Shows output from the lsblk command" \
@ -882,13 +876,13 @@ partition()
if [[ $choice == "$_Done" || $choice == "" ]]; then if [[ $choice == "$_Done" || $choice == "" ]]; then
return 0 return 0
elif [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then elif [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then
clear; tput cnorm; $choice "$device"; partition "$device" clear; tput cnorm; $choice "$device"; partition_menu "$device"
elif [[ $choice == "$_PartShowTree" ]]; then elif [[ $choice == "$_PartShowTree" ]]; then
msgbox "$_PartTitle" "\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT "$device")\n\n" msgbox "$_PartTitle" "\n\n$(lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINT "$device")\n\n"
partition "$device" partition_menu "$device"
elif [[ $choice == "$_PartWipe" ]]; then elif [[ $choice == "$_PartWipe" ]]; then
yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody" && wipe -Ifrev $device yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody" && wipe -Ifrev $device
partition "$device" partition_menu "$device"
else else
local root_size msg ret table boot_fs local root_size msg ret table boot_fs
root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 { root_size=$(lsblk -lno SIZE "$device" | awk 'NR == 1 {
@ -908,13 +902,20 @@ partition()
if yesno "$_PrepParts" "$_PartBody1 $device $msg ($size)$_PartBody3"; then if yesno "$_PrepParts" "$_PartBody1 $device $msg ($size)$_PartBody3"; then
auto_partition "$device" "$table" "$boot_fs" "$root_size" || return 1 auto_partition "$device" "$table" "$boot_fs" "$root_size" || return 1
else else
partition "$device" partition_menu "$device"
fi fi
fi fi
return 0 return 0
} }
format_as()
{
infobox "$_FSTitle" "\nRunning: ${FS_CMDS[$2]} $1\n" 1
${FS_CMDS[$2]} "$1" >/dev/null 2>$ERR
errshow "${FS_CMDS[$2]} $1"
}
decr_count() decr_count()
{ {
# remove a partition from the dialog list and decrement the number partitions left # remove a partition from the dialog list and decrement the number partitions left
@ -1160,7 +1161,7 @@ setup_boot_device()
############################################################################### ###############################################################################
# mounting menus # mounting menus
mnt_menu() mounting_menu()
{ {
# prepare partition list PARTS for dialog # prepare partition list PARTS for dialog
lvm_detect lvm_detect
@ -1196,7 +1197,7 @@ select_swap()
if ! SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"; then if ! SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"; then
SWAP_PART=""; SWAP_SIZE=""; break; return 0 SWAP_PART=""; SWAP_SIZE=""; break; return 0
fi fi
((i++)) (( i++ ))
done done
enable_swap "$MNT/swapfile" enable_swap "$MNT/swapfile"
SWAP_PART="/swapfile" SWAP_PART="/swapfile"
@ -1271,7 +1272,7 @@ select_filesystem()
fi fi
[[ $fs ]] || return 1 [[ $fs ]] || return 1
if yesno "$_FSTitle" "\nFormat $part as $fs?\n"; then if yesno "$_FSTitle" "\nFormat $part as $fs?\n"; then
format "$part" "$fs" || return 1 format_as "$part" "$fs" || return 1
else else
select_filesystem "$part" || return 1 select_filesystem "$part" || return 1
fi fi
@ -1296,11 +1297,11 @@ select_efi_partition()
if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormUefiBody $BOOT_PART $_FormUefiBody2" local msg="$_FormUefiBody $BOOT_PART $_FormUefiBody2"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format "$BOOT_PART" "vfat" format_as "$BOOT_PART" "vfat"
sleep 1 sleep 1
fi fi
else else
format "$BOOT_PART" "vfat" format_as "$BOOT_PART" "vfat"
sleep 1 sleep 1
fi fi
@ -1321,11 +1322,11 @@ select_boot_partition()
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
local msg="$_FormBiosBody $BOOT_PART $_FormBiosBody2" local msg="$_FormBiosBody $BOOT_PART $_FormBiosBody2"
if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then if yesno "$_PrepMount" "$msg" "Format $BOOT_PART" "Skip Formatting" "no"; then
format "$BOOT_PART" "ext4" format_as "$BOOT_PART" "ext4"
sleep 1 sleep 1
fi fi
else else
format "$BOOT_PART" "ext4" format_as "$BOOT_PART" "ext4"
sleep 1 sleep 1
fi fi
return 0 return 0
@ -1348,22 +1349,20 @@ select_root_partition()
select_extra_partitions() select_extra_partitions()
{ {
local part
while (( COUNT > 0 )); do while (( COUNT > 0 )); do
tput civis tput civis
local part
part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the last menu" $PARTS)" part="$(menubox "$_PrepMount " "$_ExtPartBody" "$_Done" "Return to the last menu" $PARTS)"
if [[ $part == "$_Done" || $part == "" ]]; then if [[ $part == "$_Done" || $part == "" ]]; then
break break
elif ! select_filesystem "$part"; then elif select_filesystem "$part" && select_mountpoint && mount_partition "$part" "$EXTRA_MNT"; then
break; return 1 EXTRA_MNTS="$EXTRA_MNTS $part: $EXTRA_MNT"
elif ! select_mountpoint; then [[ $EXTRA_MNT == '/usr' && $HOOKS != *usr* ]] && HOOKS="usr $HOOKS"
break; return 1 else
elif ! mount_partition "$part" "$EXTRA_MNT"; then
break; return 1 break; return 1
fi fi
EXTRA_MNTS="$EXTRA_MNTS $part: $EXTRA_MNT"
[[ $EXTRA_MNT == '/usr' && $HOOKS != *usr* ]] && HOOKS="usr $HOOKS"
done done
return 0 return 0
@ -1377,7 +1376,7 @@ install()
clear clear
tput cnorm tput cnorm
install_base install_base
printf "Generating system /etc/fstab\n" printf "Generating /etc/fstab: genfstab -U $MNT >$MNT/etc/fstab\n"
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR genfstab -U $MNT >$MNT/etc/fstab 2>$ERR
errshow 1 "genfstab -U $MNT >$MNT/etc/fstab" errshow 1 "genfstab -U $MNT >$MNT/etc/fstab"
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
@ -1385,10 +1384,13 @@ install()
package_operations package_operations
run_mkinitcpio run_mkinitcpio
install_bootloader install_bootloader
printf "Setting hardware clock with: hwclock --systohc --utc\n"
chrun "hwclock --systohc --utc" || chrun "hwclock --systohc --utc --directisa" chrun "hwclock --systohc --utc" || chrun "hwclock --systohc --utc --directisa"
create_user create_user
login_manager login_manager
printf "Setting ownership of /home/$NEWUSER\n"
chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" chrun "chown -Rf $NEWUSER:users /home/$NEWUSER"
sleep 3
edit_configs edit_configs
} }
@ -1491,20 +1493,25 @@ EOF
create_user() create_user()
{ {
printf "Creating user $NEWUSER, setting passwords, and setting shell\n" printf "Setting root password\n"
chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR
chrun "chpasswd <<< 'root:$ROOT_PASS'" errshow 1 "set root password"
if [[ $MYSHELL != *zsh ]]; then if [[ $MYSHELL != *zsh ]]; then
chrun "usermod -s $MYSHELL root" chrun "usermod -s $MYSHELL root" 2>$ERR
errshow 1 "usermod -s $MYSHELL root"
if [[ $MYSHELL == "/usr/bin/mksh" ]]; then if [[ $MYSHELL == "/usr/bin/mksh" ]]; then
cp -fv $MNT/etc/skel/.mkshrc /root/.mkshrc cp -fv $MNT/etc/skel/.mkshrc /root/.mkshrc
fi fi
fi fi
printf "Creating user $NEWUSER with: useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER\n"
local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel'
chrun "groupadd -r autologin" chrun "groupadd -r autologin" 2>$ERR
chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" errshow 1 "groupadd -r autologin"
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR
errshow 1 "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER"
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR
errshow 1 "set $NEWUSER password"
if [[ $USER_PKGS == *neovim* ]]; then if [[ $USER_PKGS == *neovim* ]]; then
mkdir -p $MNT/home/$NEWUSER/.config/nvim mkdir -p $MNT/home/$NEWUSER/.config/nvim
@ -1520,10 +1527,10 @@ create_user()
setup_xinit() setup_xinit()
{ {
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' $MNT/home/$NEWUSER/.xinitrc; then
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$NEWUSER/.xinitrc sed -i "/exec/ c exec ${LOGIN_WM}" $MNT/home/$NEWUSER/.xinitrc
else else
printf "exec $LOGIN_WM\n" > $MNT/home/$NEWUSER/.xinitrc printf "exec %s\n" "$LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc
fi fi
# automatic startx for login shells # automatic startx for login shells
@ -1660,13 +1667,13 @@ package_operations()
[[ $MYSHELL == *mksh* ]] && inpkg+=" mksh" [[ $MYSHELL == *mksh* ]] && inpkg+=" mksh"
[[ $BOOTLDR == 'grub' ]] && inpkg+=" grub" [[ $BOOTLDR == 'grub' ]] && inpkg+=" grub"
[[ $KERNEL == 'linux-lts' ]] && { inpkg+=" linux-lts"; rmpkg+=" linux"; } [[ $KERNEL == 'linux-lts' ]] && { inpkg+=" linux-lts"; rmpkg+=" linux"; }
[[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm) ]] && inpkg+="$WM_BASE_PKGS" [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm) ]] && inpkg+=" $WM_BASE_PKGS"
[[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey" [[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey"
chrun "pacman -Syyu --noconfirm" chrun "pacman -Syyu --noconfirm" 2>/dev/null
chrun "pacman -Rns $rmpkg --noconfirm" chrun "pacman -Rns $rmpkg --noconfirm" 2>/dev/null
chrun "pacman -S iputils --noconfirm" chrun "pacman -S iputils --noconfirm" 2>/dev/null
chrun "pacman -S $inpkg --needed --noconfirm" chrun "pacman -S $inpkg --needed --noconfirm" 2>/dev/null
sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers
return 0 return 0
@ -1686,10 +1693,10 @@ suckless_install()
fi fi
done done
if [[ -d /home/$NEWUSER/suckless/dwm ]]; then 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 "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h\n"
printf "You can then recompile it with 'sudo make clean install'\n" printf "You can then recompile it with 'sudo make clean install'\n"
sleep 2 sleep 3
fi fi
} }
@ -1722,7 +1729,7 @@ setup_grub()
BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE" BCMDS[grub]="${BCMDS[grub]} --target=i386-pc $BOOT_DEVICE"
else else
if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then
luks_pass "$_LuksOpen" "" || return 1 luks_pass "$_LuksOpen" 1 || return 1
fi fi
BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true && BCMDS[grub]="mount -t efivarfs efivarfs $efidir/efivars || true &&
${BCMDS[grub]} --bootloader-id=$DIST" ${BCMDS[grub]} --bootloader-id=$DIST"
@ -1863,7 +1870,7 @@ install_bootloader()
fi fi
if [[ $BOOTLDR != 'grub' ]]; then if [[ $BOOTLDR != 'grub' ]]; then
rm -f $MNT/etc/default/grub 2>dev/null rm -f $MNT/etc/default/grub 2>/dev/null
find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1 find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1
fi fi
@ -1883,6 +1890,7 @@ install_bootloader()
fi fi
if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then
printf "Copying grub efi stub to system fallback ${BMNTS[$SYS-$BOOTLDR]}/EFI/BOOT/BOOTX64.EFI\n"
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}" local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
mkdir -pv $esp/EFI/BOOT mkdir -pv $esp/EFI/BOOT
cp -fv $esp/EFI/$DIST/grubx64.efi $esp/EFI/BOOT/BOOTX64.EFI cp -fv $esp/EFI/$DIST/grubx64.efi $esp/EFI/BOOT/BOOTX64.EFI
@ -2032,13 +2040,13 @@ lvm_extra_lvs()
lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR 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"
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$_Done LV $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2." msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$_Done LV $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2."
((VOL_COUNT--)) (( VOL_COUNT-- ))
done done
return 0 return 0
} }
lvm_volume_count() lvm_volumes()
{ {
VOL_COUNT=$(dialog --cr-wrap --no-cancel --stdout \ VOL_COUNT=$(dialog --cr-wrap --no-cancel --stdout \
--backtitle "$BT" --title " $_LvmCreateVG " \ --backtitle "$BT" --title " $_LvmCreateVG " \
@ -2061,7 +2069,7 @@ lvm_partitions()
(( ${#LVM_PARTS[@]} >= 1 )) (( ${#LVM_PARTS[@]} >= 1 ))
} }
lvm_create_group() lvm_mkgroup()
{ {
lvm_group_name || return 1 lvm_group_name || return 1
@ -2091,7 +2099,6 @@ lvm_create_group()
local msg="$_LvmPvDoneBody1 $VOLUME_GROUP ($GROUP_SIZE $GROUP_SIZE_TYPE)" local msg="$_LvmPvDoneBody1 $VOLUME_GROUP ($GROUP_SIZE $GROUP_SIZE_TYPE)"
msgbox "$_LvmCreateVG" "$msg $_LvmPvDoneBody2\n" msgbox "$_LvmCreateVG" "$msg $_LvmPvDoneBody2\n"
return 0
} }
lvm_create() lvm_create()
@ -2101,8 +2108,8 @@ lvm_create()
VGROUP_MB=0 VGROUP_MB=0
umount_dir $MNT umount_dir $MNT
lvm_partitions || return 1 lvm_partitions || return 1
lvm_create_group || return 1 lvm_mkgroup || return 1
lvm_volume_count || return 1 lvm_volumes || return 1
lvm_extra_lvs || return 1 lvm_extra_lvs || return 1
lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VGROUP_MB}MB)" || 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 lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR
@ -2111,8 +2118,7 @@ lvm_create()
tput civis tput civis
sleep 0.5 sleep 0.5
local msg="${_Done}$_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2." local msg="${_Done}$_LvmPvDoneBody1 $VOLUME_GROUP-$VOLUME_NAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) $_LvmPvDoneBody2."
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")" msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg\n$(lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE "${LVM_PARTS[@]}")\n"
return 0
} }
lvm_del_vg() lvm_del_vg()
@ -2141,7 +2147,6 @@ lvm_del_all()
done done
LVM='' LVM=''
fi fi
return 0 return 0
} }
@ -2184,7 +2189,7 @@ luks_open()
return 1 return 1
fi fi
luks_pass "$_LuksOpen" "${LUKS_NAME:-cryptroot}" || return 1 luks_pass "$_LuksOpen" || return 1
infobox "$_LuksOpen" "$_LuksOpenWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0 infobox "$_LuksOpen" "$_LuksOpenWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
errshow "cryptsetup open --type luks $LUKS_PART $LUKS_NAME" errshow "cryptsetup open --type luks $LUKS_PART $LUKS_NAME"
@ -2196,46 +2201,52 @@ luks_open()
luks_pass() luks_pass()
{ {
local title="$1" local title="$1" onlypass="$2" values="" pass="" pass2="" err=0
local name="$2"
local pass pass2 while true; do
LUKS_PASS="" tput cnorm
LUKS_NAME="" if [[ $onlypass ]]; then
values="$(dialog --stdout --no-cancel --separator ';:~:;' \
--ok-label "Submit" --backtitle "$BT" --title " $title " --insecure --mixedform \
"\nEnter the password to decrypt $ROOT_PART.\n\nThis is needed to create a keyfile." 0 0 0 \
"$_Password" 1 1 "" 1 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 2 1 "" 2 $((${#_Password2} + 2)) $COLUMNS 0 1)"
else
values="$(dialog --stdout --no-cancel --separator ';:~:;' \
--ok-label "Submit" --backtitle "$BT" --title " $title " \
--insecure --mixedform "$_LuksOpenBody" 0 0 0 \
"$_Name" 1 1 "${LUKS_NAME:-cryptroot}" 1 $((${#_Name} + 2)) $COLUMNS 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1)"
tput cnorm
local values
if [[ $name == "" ]]; then
if ! values="$(dialog --stdout --no-cancel --separator ';:~:;' \
--ok-label "Submit" --backtitle "$BT" --title " $title " --insecure --mixedform \
"\nEnter the password to decrypt $ROOT_PART.\n\nThis is needed to create a keyfile." 0 0 0 \
"$_Password" 1 1 "" 1 $((${#_Password} + 2)) $COLUMNS 0 1 \
"$_Password2" 2 1 "" 2 $((${#_Password2} + 2)) $COLUMNS 0 1)"; then
return 1
fi fi
pass="$(awk -F';:~:;' '{print $1}' <<< "$values")"
pass2="$(awk -F';:~:;' '{print $2}' <<< "$values")" err=$?
else (( err == 0 )) || break
if ! values="$(dialog --stdout --no-cancel --separator ';:~:;' \
--ok-label "Submit" --backtitle "$BT" --title " $title " \ if [[ $onlypass ]]; then
--insecure --mixedform "$_LuksOpenBody" 0 0 0 \ pass="$(awk -F';:~:;' '{print $1}' <<< "$values")"
"$_Name" 1 1 "$name" 1 $((${#_Name} + 2)) $COLUMNS 0 0 \ pass2="$(awk -F';:~:;' '{print $2}' <<< "$values")"
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \ else
"$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1)"; then name="$(awk -F';:~:;' '{print $1}' <<< "$values")"
return 1 pass="$(awk -F';:~:;' '{print $2}' <<< "$values")"
pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")"
fi fi
name="$(awk -F';:~:;' '{print $1}' <<< "$values")"
pass="$(awk -F';:~:;' '{print $2}' <<< "$values")"
pass2="$(awk -F';:~:;' '{print $3}' <<< "$values")"
LUKS_NAME="$name"
fi
if [[ $pass == "" || "$pass" != "$pass2" ]]; then if [[ ! $onlypass && $name == "" ]]; then
msgbox "$_ErrTitle" "$_PassErr\n$_TryAgain" infobox "$_ErrTitle" "\nEncrypted device name cannot be empty.\n\n$_TryAgain"
luks_pass "$title" "$name" || return 1 elif [[ $pass == "" || "$pass" != "$pass2" ]]; then
fi [[ $onlypass ]] || LUKS_NAME="$name"
infobox "$_ErrTitle" "$_PassErr\n$_TryAgain"
else
[[ $onlypass ]] || LUKS_NAME="$name"
LUKS_PASS="$pass"
break
fi
done
LUKS_PASS="$pass" return $err
return 0
} }
luks_setup() luks_setup()
@ -2251,7 +2262,7 @@ luks_setup()
infobox "$_LuksEncrypt" "${_OnlyOne}: $LUKS_PART\n" 1 infobox "$_LuksEncrypt" "${_OnlyOne}: $LUKS_PART\n" 1
elif ! LUKS_PART="$(menubox "$_LuksEncrypt" "$_LuksEncryptBody" $PARTS)"; then elif ! LUKS_PART="$(menubox "$_LuksEncrypt" "$_LuksEncryptBody" $PARTS)"; then
return 1 return 1
elif ! luks_pass "$_LuksEncrypt" "${LUKS_NAME:-cryptroot}"; then elif ! luks_pass "$_LuksEncrypt"; then
return 1 return 1
fi fi
@ -2300,6 +2311,7 @@ luks_show()
luks_keyfile() luks_keyfile()
{ {
if [[ ! -e $MNT/crypto_keyfile.bin && $LUKS_PASS && $LUKS_UUID ]]; then if [[ ! -e $MNT/crypto_keyfile.bin && $LUKS_PASS && $LUKS_UUID ]]; then
printf "Creating LUKS keyfile /crypto_keyfile.bin\n"
local n local n
n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')" n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
local mkkey="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin" local mkkey="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin"
@ -2385,7 +2397,7 @@ sigint()
print4() print4()
{ {
local str="$*" local str="$*"
if [[ $COLUMNS -gt 110 && ${#str} -gt $((COLUMNS - 10)) ]]; then if [[ $COLUMNS -ge 110 && ${#str} -gt $((COLUMNS - 30)) ]]; then
str="$(awk '{ str="$(awk '{
i=2; p1=p2=p3=p4=""; p1=$1; q=int(NF / 4) i=2; p1=p2=p3=p4=""; p1=$1; q=int(NF / 4)
for (;i<=q; i++) { p1=p1" "$i } for (;i<=q; i++) { p1=p1" "$i }