Ensure presence of config file while running build-docker.sh

This commit is contained in:
Samuele Maci 2019-07-01 21:02:35 +02:00
parent 9e48fb6763
commit cdfa19ce49

View File

@ -13,18 +13,15 @@ if ! ${DOCKER} ps >/dev/null; then
exit 1
fi
CONFIG_FILE="${DIR}/config"
if [ -f "${CONFIG_FILE}" ]; then
# shellcheck disable=SC1091
source "${CONFIG_FILE}"
CONFIG_FILE=""
if [ -f "${DIR}/config" ]; then
CONFIG_FILE="${DIR}/config"
fi
while getopts "c:" flag
do
case "${flag}" in
c)
# shellcheck disable=SC1090
source "${OPTARG}"
CONFIG_FILE="${OPTARG}"
;;
*)
@ -32,6 +29,15 @@ do
esac
done
# Ensure that the confguration file is present
if test -z "${CONFIG_FILE}"; then
echo "Configuration file need to be present in '${DIR}/config' or path passed as parameter"
exit 1
else
# shellcheck disable=SC1090
source "${CONFIG_FILE}"
fi
CONTAINER_NAME=${CONTAINER_NAME:-pigen_work}
CONTINUE=${CONTINUE:-0}
PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0}