Give a brief message as to what error was encountered to help the user along.

Reviewed by:	nwhitehorn
MFC after:	2 weeks
This commit is contained in:
Andrew Thompson 2014-08-07 01:51:01 +00:00
parent 75fde29be6
commit 7041a67eee
2 changed files with 35 additions and 27 deletions

View File

@ -35,11 +35,15 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
############################################################ FUNCTIONS ############################################################ FUNCTIONS
error() { error() {
local msg
if [ -n "$1" ]; then
msg="$1\n\n"
fi
test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR
test -f $PATH_FSTAB && bsdinstall umount test -f $PATH_FSTAB && bsdinstall umount
dialog --backtitle "FreeBSD Installer" --title "Abort" \ dialog --backtitle "FreeBSD Installer" --title "Abort" \
--no-label "Exit" --yes-label "Restart" --yesno \ --no-label "Exit" --yes-label "Restart" --yesno \
"An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
else else
@ -58,7 +62,7 @@ trap true SIGINT # This section is optional
bsdinstall keymap bsdinstall keymap
trap error SIGINT # Catch cntrl-C here trap error SIGINT # Catch cntrl-C here
bsdinstall hostname || error bsdinstall hostname || error "Set hostname failed"
export DISTRIBUTIONS="base.txz kernel.txz" export DISTRIBUTIONS="base.txz kernel.txz"
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
@ -95,7 +99,7 @@ if [ -n "$FETCH_DISTRIBUTIONS" ]; then
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
MIRROR_BUTTON=$? MIRROR_BUTTON=$?
exec 3>&- exec 3>&-
test $MIRROR_BUTTON -eq 0 || error test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE export BSDINSTALL_DISTSITE
fi fi
@ -125,8 +129,8 @@ exec 3>&-
case "$PARTMODE" in case "$PARTMODE" in
"Guided") # Guided "Guided") # Guided
bsdinstall autopart || error bsdinstall autopart || error "Partitioning error"
bsdinstall mount || error bsdinstall mount || error "Failed to mount filesystem"
;; ;;
"Shell") # Shell "Shell") # Shell
clear clear
@ -136,18 +140,18 @@ case "$PARTMODE" in
"Manual") # Manual "Manual") # Manual
if f_isset debugFile; then if f_isset debugFile; then
# Give partedit the path to our logfile so it can append # Give partedit the path to our logfile so it can append
BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error"
else else
bsdinstall partedit || error bsdinstall partedit || error "Partitioning error"
fi fi
bsdinstall mount || error bsdinstall mount || error "Failed to mount filesystem"
;; ;;
"ZFS") # ZFS "ZFS") # ZFS
bsdinstall zfsboot || error bsdinstall zfsboot || error "ZFS setup failed"
bsdinstall mount || error bsdinstall mount || error "Failed to mount filesystem"
;; ;;
*) *)
error error "Unknown partitioning mode"
;; ;;
esac esac
@ -156,7 +160,7 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
# Download to a directory in the new system as scratch space # Download to a directory in the new system as scratch space
BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
mkdir -p "$BSDINSTALL_FETCHDEST" || error mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
# Try to use any existing distfiles # Try to use any existing distfiles
@ -169,13 +173,13 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
fi fi
export FTP_PASSIVE_MODE=YES export FTP_PASSIVE_MODE=YES
bsdinstall distfetch || error bsdinstall distfetch || error "Failed to fetch distribution"
export DISTRIBUTIONS="$ALL_DISTRIBUTIONS" export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
fi fi
bsdinstall checksum || error bsdinstall checksum || error "Distribution checksum failed"
bsdinstall distextract || error bsdinstall distextract || error "Distribution extract failed"
bsdinstall rootpass || error bsdinstall rootpass || error "Could not set root password"
trap true SIGINT # This section is optional trap true SIGINT # This section is optional
if [ "$NETCONFIG_DONE" != yes ]; then if [ "$NETCONFIG_DONE" != yes ]; then
@ -239,7 +243,7 @@ finalconfig() {
finalconfig finalconfig
trap error SIGINT # SIGINT is bad again trap error SIGINT # SIGINT is bad again
bsdinstall config || error bsdinstall config || error "Failed to save config"
if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
[ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \

View File

@ -38,9 +38,13 @@ f_dprintf "Began Installation at %s" "$( date )"
export BSDINSTALL_CHROOT=$1 export BSDINSTALL_CHROOT=$1
error() { error() {
local msg
if [ -n "$1" ]; then
msg="$1\n\n"
fi
dialog --backtitle "FreeBSD Installer" --title "Abort" \ dialog --backtitle "FreeBSD Installer" --title "Abort" \
--no-label "Exit" --yes-label "Restart" --yesno \ --no-label "Exit" --yes-label "Restart" --yesno \
"An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0 "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit exit
else else
@ -51,7 +55,7 @@ error() {
rm -rf $BSDINSTALL_TMPETC rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC mkdir $BSDINSTALL_TMPETC
mkdir -p $1 || error mkdir -p $1 || error "mkdir failed for $1"
test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR
@ -60,9 +64,9 @@ if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST -a -z "$BSDINSTALL_DISTSITE" ]; then
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3) BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
MIRROR_BUTTON=$? MIRROR_BUTTON=$?
exec 3>&- exec 3>&-
test $MIRROR_BUTTON -eq 0 || error test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE export BSDINSTALL_DISTSITE
fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error fetch -o $BSDINSTALL_DISTDIR/MANIFEST $BSDINSTALL_DISTSITE/MANIFEST || error "Could not download $BSDINSTALL_DISTSITE/MANIFEST"
fi fi
export DISTRIBUTIONS="base.txz" export DISTRIBUTIONS="base.txz"
@ -94,17 +98,17 @@ if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3` BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 2>&1 1>&3`
MIRROR_BUTTON=$? MIRROR_BUTTON=$?
exec 3>&- exec 3>&-
test $MIRROR_BUTTON -eq 0 || error test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE export BSDINSTALL_DISTSITE
fi fi
if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
bsdinstall distfetch || error bsdinstall distfetch || error "Failed to fetch distribution"
fi fi
bsdinstall checksum || error bsdinstall checksum || error "Distribution checksum failed"
bsdinstall distextract || error bsdinstall distextract || error "Distribution extract failed"
bsdinstall rootpass || error bsdinstall rootpass || error "Could not set root password"
trap true SIGINT # This section is optional trap true SIGINT # This section is optional
bsdinstall services bsdinstall services
@ -114,7 +118,7 @@ dialog --backtitle "FreeBSD Installer" --title "Add User Accounts" --yesno \
bsdinstall adduser bsdinstall adduser
trap error SIGINT # SIGINT is bad again trap error SIGINT # SIGINT is bad again
bsdinstall config || error bsdinstall config || error "Failed to save config"
cp /etc/resolv.conf $1/etc cp /etc/resolv.conf $1/etc
cp /etc/localtime $1/etc cp /etc/localtime $1/etc