Add more automation to early setup

This commit is contained in:
natemaia 2020-05-15 16:19:27 -07:00
parent be74c0c40f
commit c57cc058fb

View File

@ -2836,7 +2836,7 @@ ofn()
die()
{
# cleanup and exit the installer cleanly with exit code $1
local e="$1" # when e is 127 unmount /run/archiso/bootmnt and reboot
local e="${1:-$?}" # when e is 127 unmount /run/archiso/bootmnt and reboot
trap - INT
tput cnorm
@ -3158,12 +3158,14 @@ umount_dir()
chk_connect()
{
if [[ ! -f /tmp/new ]]; then
msg "Network Connect" "\nVerifying network connection\n" 0
if [[ $VM != 'none' ]] && hash nm-online > /dev/null 2>&1; then
nm-online > /dev/null 2>&1
else
ping -qc1 'archlinux.org' > /dev/null 2>&1
fi
fi
}
net_connect()
@ -3248,7 +3250,7 @@ termcol
# ensure the required packages are installed and that we're running as root on x86_64 architecture
if ! hash dialog rsync find parted curl arch-chroot >/dev/null 2>&1; then
printf "One or more required packages are missing: dialog, curl, rsync, parted, findutils, arch-install-scripts"
echo "One or more required packages are missing: dialog, curl, rsync, parted, findutils, arch-install-scripts"
die 1
elif (( UID != 0 )); then
msg "Not Root" "\nThis installer must be run as root or using sudo.\n\nExiting..\n" 2
@ -3256,34 +3258,23 @@ elif (( UID != 0 )); then
elif ! grep -qwm 1 'lm' /proc/cpuinfo; then
msg "Not x86_64 Architecture" "\nThis installer only supports x86_64 architectures.\n\nExiting..\n" 2
die 1
elif [[ ! -d $MNT ]]; then
msg "No Mount Directory" "\nThe installer expects an existing directory for mounting.\n\nExiting..\n" 2
die 1
fi
# trap ^C to perform cleanup
trap 'printf "\n^C\n" && die 1' INT
while getopts ":htl:dnr:b:" OPT; do
while getopts ":htl:Dnr:b:m:d:" OPT; do
case "$OPT" in
n)
NOMOUNT=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
m)
MNT="$OPTARG"
;;
d)
DIST="$OPTARG"
;;
D)
debug
;;
h)
@ -3292,11 +3283,26 @@ while getopts ":htl:dnr:b:" OPT; do
t)
TEARFREE=true
;;
r)
if [[ ! -b $OPTARG ]]; then
msg "Invalid Root" "\nThe installer expects a full path to a block device for root.\n\nExiting..\n" 2
die 1
fi
ROOT="$OPTARG"
;;
b)
if [[ ! -b $OPTARG ]]; then
msg "Invalid Boot" "\nThe installer expects a full path to a block device for boot.\n\nExiting..\n" 2
die 1
fi
BOOT="$OPTARG"
;;
l)
if [[ "${!WM_SESSIONS[*]}" =~ $OPTARG ]]; then
live "$OPTARG"
else
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
;;
\?)
@ -3306,12 +3312,20 @@ while getopts ":htl:dnr:b:" OPT; do
esac
done
if [[ ! -d $MNT ]]; then
msg "Invalid Mountpoint" "\nThe installer expects an existing directory for mounting.\n\nExiting..\n" 2
die 1
elif [[ -z $DIST ]]; then
msg "Invalid Distribution" "\nThe distribution name cannot be empty.\n\nExiting..\n" 2
die 1
fi
system_identify
system_devices
if [[ $NOMOUNT ]]; then
if [[ (-z $ROOT || ($SYS == 'UEFI' && -z $BOOT)) ]]; then
msg "Not Enough Partitions" "$_errpart" 0
if [[ -z $ROOT || ($SYS == 'UEFI' && -z $BOOT) ]]; then
msg "Invalid Partitions" "$_errpart" 0
die 1
fi
if [[ $BOOT ]]; then
@ -3320,12 +3334,13 @@ if [[ $NOMOUNT ]]; then
fi
fi
if [[ -f /tmp/hassetfont ]]; then
if [[ $TERM == 'linux' && -f /tmp/hassetfont ]]; then
FONT="$(< /tmp/hassetfont)"
setfont "$FONT"
else
fontsize=16
while [[ ! -f /tmp/hassetfont ]]; do
FONT="ter-i${fontsize}n"
while [[ $TERM == 'linux' && ! -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" \
@ -3349,6 +3364,18 @@ elif ! net_connect; then
die 1
fi
if [[ ! -f /tmp/new ]]; then
msg "Installer Update" "\nChecking that the installer version is the newest.\n" 0
if curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/archlabs-installer -o /tmp/new; then
if (( $(vercmp "$(awk -F= '/^VER=/ {print $2}' /tmp/archlabs-installer)" "$VER") > 0 )); then
cp /tmp/new /usr/bin/archlabs-installer && exec archlabs-installer "$@"
die
fi
else
msg "Download Failed" "\nUnable to download the latest version, continuing with the current.\n" 2
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