From 28705cabe381a624b25346841a78b72df54303ab Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Sun, 25 Sep 2022 12:39:42 +0200 Subject: [PATCH] added ability to one-time override the variables by setting the variables externally at runtime when invoking the utility --- deploy.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/deploy.sh b/deploy.sh index 59da192..6bd4b81 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,18 +1,24 @@ #/usr/bin/env bash set -e -# Check for the source server (with default) -DEPLOY_SOURCE_FILE="${HOME}/.deploy_source" -DEPLOY_SOURCE="https://git.bjphoster.com/deployments" -if [ -f "${DEPLOY_SOURCE_FILE}" ]; then - . "${DEPLOY_SOURCE_FILE}" +# Check if the source server variable has already been set externally +if [ -z "${DEPLOY_SOURCE}" ]; then + # Check for the source server (with default) + DEPLOY_SOURCE_FILE="${HOME}/.deploy_source" + DEPLOY_SOURCE="https://git.bjphoster.com/deployments" + if [ -f "${DEPLOY_SOURCE_FILE}" ]; then + . "${DEPLOY_SOURCE_FILE}" + fi fi -# Check for the deploy position (with default) -DEPLOY_DESTINATION_FILE="${HOME}/.deploy_destination" -DEPLOY_DESTINATION="/opt" -if [ -f "${DEPLOY_DESTINATION_FILE}" ]; then - . "${DEPLOY_DESTINATION_FILE}" +# Check if the deploy position variable has already been set externally +if [ -z "${DEPLOY_DESTINATION}" ]; then + # Check for the deploy position (with default) + DEPLOY_DESTINATION_FILE="${HOME}/.deploy_destination" + DEPLOY_DESTINATION="/opt" + if [ -f "${DEPLOY_DESTINATION_FILE}" ]; then + . "${DEPLOY_DESTINATION_FILE}" + fi fi # Check if the correct usage is respected