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 exit 1
fi fi
CONFIG_FILE=""
if [ -f "${DIR}/config" ]; then
CONFIG_FILE="${DIR}/config" CONFIG_FILE="${DIR}/config"
if [ -f "${CONFIG_FILE}" ]; then
# shellcheck disable=SC1091
source "${CONFIG_FILE}"
fi fi
while getopts "c:" flag while getopts "c:" flag
do do
case "${flag}" in case "${flag}" in
c) c)
# shellcheck disable=SC1090
source "${OPTARG}"
CONFIG_FILE="${OPTARG}" CONFIG_FILE="${OPTARG}"
;; ;;
*) *)
@ -32,6 +29,15 @@ do
esac esac
done 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} CONTAINER_NAME=${CONTAINER_NAME:-pigen_work}
CONTINUE=${CONTINUE:-0} CONTINUE=${CONTINUE:-0}
PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0} PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0}