frontend: reorder checks

perform the check that the script exists before sorting out the environment
to give it, or checking root privileges.

Gbp-Dch: Short
This commit is contained in:
Lyndon Brown 2020-03-30 12:08:12 +01:00 committed by Raphaël Hertzog
parent 8ffe48d8f3
commit b28095bd56
1 changed files with 15 additions and 16 deletions

View File

@ -42,22 +42,6 @@ esac
COMMAND="${1}"
shift
ENV=""
if [ "${COMMAND}" != "config" ]; then
# Checking user account
if [ "$(id -u)" -ne "0" ]; then
Echo_error "Root privileges needed!"
exit 1
fi
fi
for _FILE in config/environment config/environment.binary; do
if [ -e "${_FILE}" ]; then
ENV="${ENV} $(grep -v '^#' ${_FILE})"
fi
done
if [ -x "${LIVE_BUILD}/scripts/build/${COMMAND}" ]; then
# User has live-build copied locally in the system
SCRIPT="${LIVE_BUILD}/scripts/build/${COMMAND}"
@ -75,6 +59,21 @@ else
exit 1
fi
if [ "${COMMAND}" != "config" ]; then
# Checking user account
if [ "$(id -u)" -ne "0" ]; then
Echo_error "Root privileges needed!"
exit 1
fi
fi
ENV=""
for _FILE in config/environment config/environment.binary; do
if [ -e "${_FILE}" ]; then
ENV="${ENV} $(grep -v '^#' ${_FILE})"
fi
done
_CMD_LABEL="lb ${COMMAND}"
if [ "${_COLOR_OUT}" = "true" ]; then
_CMD_LABEL="${CYAN}${_CMD_LABEL}${NO_COLOR}"