[ -r "${INSTALL_SOURCE_DIR}/${PACKAGES_DOT_MAIN}/${DOM0_ROOTFS}" ] || exit ${CheckFail}
}
-INTERACTIVE=0
-interactive || INTERACTIVE=1
-
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Verifying repository." 5
+mixedgauge "Verifying repository." 5
# Verify the repo:
if ! validate_repo "/${PACKAGES_DOT_MAIN}" "${INTERACTIVE}" ; then
- [ ${INTERACTIVE} -ne 0 ] || dialog --ok-label Continue --msgbox "ERROR: Install media verification failed." 0 0
+ ! interactive || dialog --ok-label Continue --msgbox "ERROR: Install media verification failed." 0 0
exit ${CheckFail}
fi
# Make the repo available for the installer:
link_bootmedia_repo
-if [ ${INTERACTIVE} -ne 0 ] ; then
+if ! interactive ; then
not_previous $@ || exit ${Previous}
fi
exit ${Continue}
return 0
}
-INTERACTIVE=0
-interactive || INTERACTIVE=1
-
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Obtaining IP address..." 30
+mixedgauge "Obtaining IP address..." 30
if ! apply_config_to_nic ; then
echo "Failure when bringing up ${NIC}.">&2
- if [ ${INTERACTIVE} -eq 0 ] ; then
+ if interactive ; then
hide_cursor
do_cmd dialog --ok-label Continue --msgbox "\nError: failed to obtain IP address." 7 40
exit ${NoAddress}
# FIXME: distinguish Abort from BadConfig exit conditions.
-#-----------------------------------------------------------
-INTERACTIVE=0
-interactive || INTERACTIVE=1
-
#-----------------------------------------------------------
wget_file()
{
BASE_URL="$1"
PERCENT="2"
- [ ${INTERACTIVE} -ne 0 ] || mixedgauge "Downloading manifest..." "${PERCENT}"
+ mixedgauge "Downloading manifest..." "${PERCENT}"
wget_file "${BASE_URL}" "${PACKAGES_DOT_MAIN}/${REPOSITORY_FILENAME}" || return 1
wget_file "${BASE_URL}" "${PACKAGES_DOT_MAIN}/${PKGDATA_FILENAME}" || return 1
PKG_LIST="$(package_list ${PKGDATA_FILE})"
PERCENT="10" # FIXME: proper calculation
for FILENAME in ${PKG_LIST} ; do
- [ ${INTERACTIVE} -ne 0 ] || mixedgauge "Downloading ${FILENAME}..." "${PERCENT}"
+ mixedgauge "Downloading ${FILENAME}..." "${PERCENT}"
wget_file "${BASE_URL}" "${PACKAGES_DOT_MAIN}/${FILENAME}" || return 1
PERCENT="$(( PERCENT + 50 ))" # FIXME: proper calculation
done
;;
esac
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Download complete." "100"
+mixedgauge "Download complete." "100"
# FIXME: when checking to see if download was successful:
# if not: if interactive, return ${Previous}, else return ${Abort}
# A precautionary umount, failure here is fine
umount "${OPTICAL_MOUNT}" 2>/dev/null
-INTERACTIVE=0
-interactive || INTERACTIVE=1
-
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Mounting optical device." 30
+mixedgauge "Mounting optical device." 30
mkdir -p "${OPTICAL_MOUNT}"
mount "${OPTICAL_DEV}" "${OPTICAL_MOUNT}" || exit ${MountFail}
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Mounted optical device." 100
+mixedgauge "Mounted optical device." 100
exit ${Continue}
DEV="/dev/${TARGET_DISK}"
-# FIXME:
-if ! interactive ; then
- d(){ :;} # redefine d to nothing so no dialogs are shown
-fi
-
mixedgauge "Removing previous partitions." 0
do_cmd vgchange -a n >&2 || die
for i in ${DEV}[1-4]
exit ${Continue}
fi
-INTERACTIVE=0
-interactive || INTERACTIVE=1
-
# If interactive, ask:
-if [ "${OPTICAL_VERIFY}" = "ask_or_yes" ] && [ ${INTERACTIVE} -eq 0 ] ; then
+if [ "${OPTICAL_VERIFY}" = "ask_or_yes" ] && interactive ; then
dialog --yes-label Verify --no-label Skip --yesno "\n Verify the CD-ROM media?" 7 40
OPT=$?
[ "$OPT" != "255" ] || exit ${Previous}
fi
-[ ${INTERACTIVE} -ne 0 ] || mixedgauge "Verifying repository." 5
+mixedgauge "Verifying repository." 5
# Verify the repo:
if ! validate_repo "${OPTICAL_MOUNT}/${PACKAGES_DOT_MAIN}" "${INTERACTIVE}" ; then
- [ ${INTERACTIVE} -ne 0 ] || dialog --ok-label Continue --msgbox "ERROR: CD-ROM verification failed." 0 0
+ ! interactive || dialog --ok-label Continue --msgbox "ERROR: CD-ROM verification failed." 0 0
exit ${VerifyFail}
fi
# Make the repo available for the installer:
link_optical_repo
-if [ "${OPTICAL_VERIFY}" != "ask_or_yes" ] || [ ${INTERACTIVE} -ne 0 ] ; then
+if [ "${OPTICAL_VERIFY}" != "ask_or_yes" ] || ! interactive ; then
not_previous $@ || exit ${Previous}
fi
exit ${Continue}
text="$1"
percent="$2"
hide_cursor
- d --mixedgauge "$text" 0 0 "$percent"
+ if [ ${INTERACTIVE} -ne 0 ] ; then
+ echo "${text}">&2
+ else
+ d --mixedgauge "$text" 0 0 "$percent"
+ fi
}
-interactive()
+# Make the 'interactive' function cheaper by only reading
+# the contents of the config file once, here, and caching.
+read_interactive()
{
# 0: is interactive
# 1: non-interactive
grep -qi "AUTOMATED=True" <"${AUTOMATED_CONF}" || return 0
return 1
}
+export INTERACTIVE=0
+read_interactive || export INTERACTIVE=1
+interactive()
+{
+ return ${INTERACTIVE}
+}
KCMD_LINE="/install/data/kcmdline" # copy of /proc/cmdline
MANIFEST_SIZE="$(sed -ne 's/^\S\+\s\+\(\S\+\)\s\+\(\S\+\s\+\)\{3\}\('${FILENAME}'\)\s.*$/\1/p' <${PKGDATA_FILE})"
FILE="${REPO_DIR}/${FILENAME}"
- [ ${INTERACTIVE} -ne 0 ] || mixedgauge "Verifying: ${FILENAME}" "${PERCENT}"
+ mixedgauge "Verifying: ${FILENAME}" "${PERCENT}"
FILE_MD5SUM="$(md5sum ${FILE} | cut -f1 -d' ')"
PERCENT="$(( PERCENT + 50 ))" # FIXME: proper calculation