From cdfa19ce49de762a677f3eb15c915448b5bef956 Mon Sep 17 00:00:00 2001 From: Samuele Maci Date: Mon, 1 Jul 2019 21:02:35 +0200 Subject: [PATCH] Ensure presence of config file while running build-docker.sh --- build-docker.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 71e52f8..ea65d70 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -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}