From 37b090d23c419dc7bb6a3c7bea2d9df16edc9bf5 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Sun, 4 Aug 2024 19:51:30 -0400 Subject: [PATCH] Update installer for error checking and halting --- gentoo-install.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gentoo-install.sh b/gentoo-install.sh index bf13a67..bcf8650 100755 --- a/gentoo-install.sh +++ b/gentoo-install.sh @@ -42,6 +42,14 @@ function show_help() { exit 0 } +function errormsg() { + local err=$1 + shift + + echo "$*" >&2 + exit "$err" +} + function prepare_disk() { if [[ "$DEBUG" ]]; then local cmd="echo" @@ -228,13 +236,13 @@ function stage_step() { #FIXME check $INSTALL_STAGE for http or local file if [[ "$INSTALL_STAGE" == http* ]]; then 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##*/}" else s4file="${INSTALL_STAGE}" 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} rm -rf "$HOME/gen2stage4"