Update installer for error checking and halting

This commit is contained in:
Eric Renfro 2024-08-04 19:51:30 -04:00
parent d5bcff89bf
commit 37b090d23c
Signed by: psi-jack
SSH key fingerprint: SHA256:1TKB8Z257L8EHK8GWNxKgMhD8a+FAR+f+j3nnlcuNVM

View file

@ -42,6 +42,14 @@ function show_help() {
exit 0 exit 0
} }
function errormsg() {
local err=$1
shift
echo "$*" >&2
exit "$err"
}
function prepare_disk() { function prepare_disk() {
if [[ "$DEBUG" ]]; then if [[ "$DEBUG" ]]; then
local cmd="echo" local cmd="echo"
@ -228,13 +236,13 @@ function stage_step() {
#FIXME check $INSTALL_STAGE for http or local file #FIXME check $INSTALL_STAGE for http or local file
if [[ "$INSTALL_STAGE" == http* ]]; then if [[ "$INSTALL_STAGE" == http* ]]; then
s4file="${INSTALL_STAGE##*/}" s4file="${INSTALL_STAGE##*/}"
${cmd} curl -O "/mnt/gentoo/${s4file}" "$INSTALL_STAGE" ${cmd} curl -O "/mnt/gentoo/${s4file}" "$INSTALL_STAGE" || errormsg 1 "Failed to download stage4 archive"
s4file="/mnt/gentoo/${INSTALL_STAGE##*/}" s4file="/mnt/gentoo/${INSTALL_STAGE##*/}"
else else
s4file="${INSTALL_STAGE}" s4file="${INSTALL_STAGE}"
fi fi
${cmd} git clone "https://github.com/erenfro/gen2stage4" "$HOME/gen2stage4" ${cmd} git clone "https://github.com/erenfro/gen2stage4" "$HOME/gen2stage4" || errormsg 1 "Failed to download gen2stage4"
${cmd} "$HOME/gen2stage4/gen2stage4" -q -t /mnt/gentoo "$s4file" ${cmd} "$HOME/gen2stage4/gen2stage4" -q -t /mnt/gentoo "$s4file"
${cmd} rm -rf "$HOME/gen2stage4" ${cmd} rm -rf "$HOME/gen2stage4"