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,13 +370,38 @@ _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 tput civis
dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " \ dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " Prepare " \
--default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \ --default-item $SEL --cancel-label 'Exit' --menu "$_prep" 0 0 0 \
1 "Show device tree" \ 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"
read -r SEL < "$ANS"
case $SEL in
1) prechecks 0 && { select_bootldr || (( SEL-- )); } ;;
2) prechecks 1 && { select_mkuser || (( SEL-- )); } ;;
3) prechecks 2 && { select_config || (( SEL-- )); } ;;
4) prechecks 3 && { select_sessions || (( SEL-- )); } ;;
5) prechecks 3 && { select_packages || (( SEL-- )); } ;;
6) prechecks 3 && select_usercmd ;;
7) prechecks 3 && select_show ;;
8) prechecks 3 && install_main ;;
*) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0
esac
else
(( SEL < 13 )) && (( SEL++ ))
tput civis
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" \ 2 "Partitioning" \
3 "LUKS encryption" \ 3 "LUKS encryption" \
4 "Logical volume management" \ 4 "Logical volume management" \
@ -388,13 +413,10 @@ main()
10 "Select additional packages" \ 10 "Select additional packages" \
11 "Run a command on the installed system" \ 11 "Run a command on the installed system" \
12 "View configuration and command selections" \ 12 "View configuration and command selections" \
13 "* Confirm choices and start the installation" 2> "$ANS" 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; }
# if the operation returns an error we decrement SEL, prechecks() will
# also set SEL to even further back based on what is needed to continue
case $SEL in case $SEL in
1) part_show ;; 1) part_show ;;
2) part_menu || (( SEL-- )) ;; 2) part_menu || (( SEL-- )) ;;
@ -411,6 +433,7 @@ main()
13) prechecks 3 && install_main ;; 13) prechecks 3 && install_main ;;
*) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0 *) yesno "Exit" "\nUnmount partitions (if any) and exit the installer?\n" && die 0
esac esac
fi
} }
select_show() select_show()
@ -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; }
@ -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
if [[ $NOMOUNT ]]; then
if [[ (-z $ROOT || ($SYS == 'UEFI' && -z $BOOT)) ]]; then
msg "Not Enough Partitions" "$_errpart" 0
die 1
fi
if [[ $BOOT ]]; then
part_bootdev
SEP_BOOT=true
fi
fi
if [[ -f /tmp/hassetfont ]]; then
FONT="$(< /tmp/hassetfont)"
setfont "$FONT"
else
fontsize=16 fontsize=16
while :; do while [[ ! -f /tmp/hassetfont ]]; do
dlg fontsize menu "Font Size" "\nSelect a font size from the list below.\n\nDefault: 16" \ 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" \ 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" \ 20 "setfont ter-i20n" 22 "setfont ter-i22n" 24 "setfont ter-i24n" 28 "setfont ter-i28n" \
32 "setfont ter-i32n" || break 32 "setfont ter-i32n" || break
FONT="ter-i${fontsize}n" FONT="ter-i${fontsize}n"
setfont "$FONT" setfont "$FONT"
yesno "Font Size" "\nKeep the currently set font size?\n" && break yesno "Font Size" "\nKeep the currently set font size?\n" && echo "ter-i${fontsize}n" > /tmp/hassetfont
done 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