Initial work on mountless install

This commit is contained in:
natemaia 2020-05-12 19:50:35 -07:00
parent 62125fc64b
commit ef9edc0d62

View File

@ -7,7 +7,7 @@
# shellcheck disable=SC2086,SC2046,SC2254 # shellcheck disable=SC2086,SC2046,SC2254
VER=2.1.47 VER=2.1.48
# default values { # default values {
@ -370,47 +370,70 @@ _lvmerrlvsize="\nInvalid value Entered.\n\nMust be a numeric value with 'M' (meg
main() main()
{ {
# increment SEL every time we enter main() if we're not at the end of the menu if [[ $NOMOUNT ]]; then
(( SEL < 13 )) && (( SEL++ )) (( SEL < 8 )) && (( SEL++ ))
tput civis
dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " \
--default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \
1 "* Select bootloader" \
2 "* Username and password" \
3 "* System configuration" \
4 "Select window manager or desktop" \
5 "Select additional packages" \
6 "Run a command on the installed system" \
7 "View configuration and command selections" \
8 "* Confirm choices and finish installation" 2> "$ANS"
tput civis read -r SEL < "$ANS"
dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " \ case $SEL in
--default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \ 1) prechecks 0 && { select_bootldr || (( SEL-- )); } ;;
1 "Show device tree" \ 2) prechecks 1 && { select_mkuser || (( SEL-- )); } ;;
2 "Partitioning" \ 3) prechecks 2 && { select_config || (( SEL-- )); } ;;
3 "LUKS encryption" \ 4) prechecks 3 && { select_sessions || (( SEL-- )); } ;;
4 "Logical volume management" \ 5) prechecks 3 && { select_packages || (( SEL-- )); } ;;
5 "* Mount partitions" \ 6) prechecks 3 && select_usercmd ;;
6 "* Select bootloader" \ 7) prechecks 3 && select_show ;;
7 "* Username and password" \ 8) prechecks 3 && install_main ;;
8 "* System configuration" \ *) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0
9 "Select window manager or desktop" \ esac
10 "Select additional packages" \ else
11 "Run a command on the installed system" \ (( SEL < 13 )) && (( SEL++ ))
12 "View configuration and command selections" \ tput civis
13 "* Confirm choices and start the installation" 2> "$ANS" dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " \
--default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \
1 "Device tree" \
2 "Partitioning" \
3 "LUKS encryption" \
4 "Logical volume management" \
5 "* Mount partitions" \
6 "* Select bootloader" \
7 "* Username and password" \
8 "* System configuration" \
9 "Select window manager or desktop" \
10 "Select additional packages" \
11 "Run a command on the installed system" \
12 "View configuration and command selections" \
13 "* Confirm choices and finish installation" 2> "$ANS"
read -r SEL < "$ANS" read -r SEL < "$ANS"
[[ -z $WARN && $SEL =~ (2|5) ]] && { msg "Data Warning" "$_warn"; WARN=true; } [[ -z $WARN && $SEL =~ (2|5) ]] && { msg "Data Warning" "$_warn"; WARN=true; }
case $SEL in
# if the operation returns an error we decrement SEL, prechecks() will 1) part_show ;;
# also set SEL to even further back based on what is needed to continue 2) part_menu || (( SEL-- )) ;;
case $SEL in 3) luks_menu || (( SEL-- )) ;;
1) part_show ;; 4) lvm_menu || (( SEL-- )) ;;
2) part_menu || (( SEL-- )) ;; 5) mount_menu || (( SEL-- )) ;;
3) luks_menu || (( SEL-- )) ;; 6) prechecks 0 && { select_bootldr || (( SEL-- )); } ;;
4) lvm_menu || (( SEL-- )) ;; 7) prechecks 1 && { select_mkuser || (( SEL-- )); } ;;
5) mount_menu || (( SEL-- )) ;; 8) prechecks 2 && { select_config || (( SEL-- )); } ;;
6) prechecks 0 && { select_bootldr || (( SEL-- )); } ;; 9) prechecks 3 && { select_sessions || (( SEL-- )); } ;;
7) prechecks 1 && { select_mkuser || (( SEL-- )); } ;; 10) prechecks 3 && { select_packages || (( SEL-- )); } ;;
8) prechecks 2 && { select_config || (( SEL-- )); } ;; 11) prechecks 3 && select_usercmd ;;
9) prechecks 3 && { select_sessions || (( SEL-- )); } ;; 12) prechecks 3 && select_show ;;
10) prechecks 3 && { select_packages || (( SEL-- )); } ;; 13) prechecks 3 && install_main ;;
11) prechecks 3 && select_usercmd ;; *) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0
12) prechecks 3 && select_show ;; esac
13) prechecks 3 && install_main ;; fi
*) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0
esac
} }
select_show() select_show()
@ -1037,7 +1060,7 @@ part_pretty()
[[ $dev && $size ]] || continue [[ $dev && $size ]] || continue
s=${size%%__*} s=${size%%__*}
size_t="${s: -1:1}" size_t="${s: -1:1}"
isize=${s:0:-1} isize=${s:0: -1}
isize=${isize%.*} isize=${isize%.*}
if [[ $dev = /dev/nvme* ]]; then if [[ $dev = /dev/nvme* ]]; then
model=$(lsblk -lno MODEL "${dev%p[1-9]}" | awk '{gsub(/ |\t/, "_"); print}') model=$(lsblk -lno MODEL "${dev%p[1-9]}" | awk '{gsub(/ |\t/, "_"); print}')
@ -1160,8 +1183,8 @@ part_countdec()
mount_menu() mount_menu()
{ {
msg "Mount Menu" "\nGathering device and partition information.\n" 1
is_bg_install || return 0 is_bg_install || return 0
msg "Mount Menu" "\nGathering device and partition information.\n" 1
lvm_detect lvm_detect
umount_dir "$MNT" umount_dir "$MNT"
part_find 'part|lvm|crypt' || { SEL=2; return 1; } part_find 'part|lvm|crypt' || { SEL=2; return 1; }
@ -1279,7 +1302,7 @@ select_root()
while read -r dev size; do while read -r dev size; do
s=${size%%__*} s=${size%%__*}
size_t="${s: -1:1}" size_t="${s: -1:1}"
isize=${s:0:-1} isize=${s:0: -1}
isize=${isize%.*} isize=${isize%.*}
if ! [[ $size_t == 'M' || ($size_t == 'G' && $isize -lt 8) ]]; then if ! [[ $size_t == 'M' || ($size_t == 'G' && $isize -lt 8) ]]; then
pts+="$dev $size " pts+="$dev $size "
@ -1313,7 +1336,7 @@ select_swap()
while read -r dev size; do # walk partition list and skip ones that are > 64G while read -r dev size; do # walk partition list and skip ones that are > 64G
s=${size%%__*} s=${size%%__*}
size_t="${s: -1:1}" size_t="${s: -1:1}"
isize=${s:0:-1} isize=${s:0: -1}
isize=${isize%.*} isize=${isize%.*}
if ! [[ $size_t == 'T' || ($size_t == 'G' && $isize -gt 64) ]]; then if ! [[ $size_t == 'T' || ($size_t == 'G' && $isize -gt 64) ]]; then
pts+="$dev $size " pts+="$dev $size "
@ -2415,7 +2438,7 @@ lvm_mkgroup()
VGROUP_MB=$SIZE VGROUP_MB=$SIZE
fi fi
msg "$_lvmnew" "\nVolume group $VGROUP (${SIZE}$SIZE_UNIT) successfully created\n" msg "$_lvmnew" "\nVolume group $VGROUP (${SIZE}$SIZE_UNIT) successfully created\n" 2
} }
lvm_del_all() lvm_del_all()
@ -2471,6 +2494,7 @@ lvm_partitions()
{ {
part_find 'part|crypt' || return 1 part_find 'part|crypt' || return 1
PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")" PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")"
[[ $LUKS && $LUKS_PART ]] && part_countdec $LUKS_PART
dlg LVM_PARTS check "$_lvmnew" "\nSelect the partition(s) to use for the physical volume (PV)." $PARTS dlg LVM_PARTS check "$_lvmnew" "\nSelect the partition(s) to use for the physical volume (PV)." $PARTS
} }
@ -2537,6 +2561,7 @@ luks_open()
if (( PART_COUNT == 1 )); then if (( PART_COUNT == 1 )); then
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")" LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
else else
[[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS
dlg LUKS_PART menu "$_luksopen" "\nSelect which partition to open." $PARTS dlg LUKS_PART menu "$_luksopen" "\nSelect which partition to open." $PARTS
fi fi
@ -2598,6 +2623,7 @@ luks_setup()
elif (( PART_COUNT == 1 )); then elif (( PART_COUNT == 1 )); then
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")" LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
else else
[[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS
dlg LUKS_PART menu "$_luksnew" "\nSelect the partition you want to encrypt." $PARTS dlg LUKS_PART menu "$_luksnew" "\nSelect the partition you want to encrypt." $PARTS
fi fi
@ -3069,11 +3095,34 @@ fi
# trap ^C to perform cleanup # trap ^C to perform cleanup
trap 'printf "\n^C\n" && die 1' INT trap 'printf "\n^C\n" && die 1' INT
while getopts ":htl:d" OPT; do while getopts ":htl:dnr:b:" OPT; do
case "$OPT" in case "$OPT" in
d) debug ;; n)
h) usage "$0" ;; NOMOUNT=true
t) TEARFREE=true ;; ;;
r)
if [[ ! -b $OPTARG ]]; then
echo "invalid root: $OPTARG"
die 1
fi
ROOT=$OPTARG
;;
b)
if [[ ! -b $OPTARG ]]; then
echo "invalid boot: $OPTARG"
die 1
fi
BOOT=$OPTARG
;;
d)
debug
;;
h)
usage "$0"
;;
t)
TEARFREE=true
;;
l) l)
if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then
live "$OPTARG" live "$OPTARG"
@ -3081,24 +3130,42 @@ while getopts ":htl:d" OPT; do
echo "error: invalid session for -l, see -h for help"; die 1 echo "error: invalid session for -l, see -h for help"; die 1
fi fi
;; ;;
\?) echo "error: invalid option: -$OPTARG"; die 1 ;; \?)
echo "invalid option: $OPTARG"
die 1
;;
esac esac
done done
system_identify system_identify
system_devices system_devices
fontsize=16 if [[ $NOMOUNT ]]; then
while :; do if [[ (-z $ROOT || ($SYS == 'UEFI' && -z $BOOT)) ]]; then
dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \ msg "Not Enough Partitions" "$_errpart" 0
12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \ die 1
20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \ fi
32 "setfont ter-i32n" || break if [[ $BOOT ]]; then
part_bootdev
SEP_BOOT=true
fi
fi
FONT="ter-i${fontsize}n" if [[ -f /tmp/hassetfont ]]; then
FONT="$(< /tmp/hassetfont)"
setfont "$FONT" setfont "$FONT"
yesno "Font Size" "\nKeep the currently set font size?\n" && break else
done fontsize=16
while [[ ! -f /tmp/hassetfont ]]; do
dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \
12 "setfont ter-i12n" 14 "setfont ter-i14n" 16 "setfont ter-i16n" 18 "setfont ter-i18n" \
20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \
32 "setfont ter-i32n" || break
FONT="ter-i${fontsize}n"
setfont "$FONT"
yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/hassetfont
done
fi
msg "Welcome to the $DIST Installer" "$_welcome" msg "Welcome to the $DIST Installer" "$_welcome"
@ -3110,6 +3177,12 @@ elif ! net_connect; then
die 1 die 1
fi fi
if [[ $NOMOUNT ]]; then
wrn="\nA background install process will begin early when using -n flag\n\nSome files may be overwritten during the process\n"
yesno "Data Warning" "$wrn\nProceed?\n" || die 0
install_background
fi
while :; do while :; do
main main
done done