frontend: tidy
no need to have exit in both conditions no need to have most of the script within a case branch when all other cases result in an exit. Gbp-Dch: Short
This commit is contained in:
parent
9f42bc1bdc
commit
67930f3e6e
94
frontend/lb
94
frontend/lb
|
@ -21,14 +21,12 @@ USAGE="lb {clean|config|build}"
|
||||||
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
if [ $(which man) ]
|
if [ $(which man) ]; then
|
||||||
then
|
|
||||||
man lb
|
man lb
|
||||||
exit 0
|
|
||||||
else
|
else
|
||||||
${0} --usage
|
${0} --usage
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
""|-u|--usage)
|
""|-u|--usage)
|
||||||
|
@ -39,53 +37,43 @@ case "${1}" in
|
||||||
echo "${VERSION}"
|
echo "${VERSION}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
|
||||||
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}"
|
|
||||||
elif [ -x "local/live-build/scripts/build/${COMMAND}" ]
|
|
||||||
then
|
|
||||||
# User has live-build copied locally in the config
|
|
||||||
SCRIPT="local/live-build/scripts/build/${COMMAND}"
|
|
||||||
elif [ -x /usr/lib/live/build/${COMMAND} ]
|
|
||||||
then
|
|
||||||
# User has live-build installed in the system
|
|
||||||
SCRIPT=/usr/lib/live/build/"${COMMAND}"
|
|
||||||
elif [ $(which "${COMMAND}") ]
|
|
||||||
then
|
|
||||||
# User has live-build commands in path
|
|
||||||
SCRIPT="${COMMAND}"
|
|
||||||
else
|
|
||||||
Echo_error "No such script: ${COMMAND}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
Echo "[%s] %s" "$(date +'%F %T')" "lb ${COMMAND} $(echo ${@})"
|
|
||||||
${ENV} exec "${SCRIPT}" "${@}"
|
|
||||||
;;
|
|
||||||
esac
|
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}"
|
||||||
|
elif [ -x "local/live-build/scripts/build/${COMMAND}" ]; then
|
||||||
|
# User has live-build copied locally in the config
|
||||||
|
SCRIPT="local/live-build/scripts/build/${COMMAND}";
|
||||||
|
elif [ -x /usr/lib/live/build/${COMMAND} ]; then
|
||||||
|
# User has live-build installed in the system
|
||||||
|
SCRIPT=/usr/lib/live/build/"${COMMAND}"
|
||||||
|
elif [ $(which "${COMMAND}") ]; then
|
||||||
|
# User has live-build commands in path
|
||||||
|
SCRIPT="${COMMAND}"
|
||||||
|
else
|
||||||
|
Echo_error "No such script: ${COMMAND}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
Echo "[%s] %s" "$(date +'%F %T')" "lb ${COMMAND} $(echo ${@})"
|
||||||
|
${ENV} exec "${SCRIPT}" "${@}"
|
||||||
|
|
Loading…
Reference in New Issue