fixed indents

pull/6241/head
tomo 2 months ago
parent 0ce28302bd
commit cfe32265a8
No known key found for this signature in database
GPG Key ID: 5FB8BCB7CE54EE44

@ -9,106 +9,106 @@ MULTIDEPLOY_FILENAME="multideploy.yaml"
# domain keyfile certfile cafile fullchain pfx # domain keyfile certfile cafile fullchain pfx
multideploy_deploy() { multideploy_deploy() {
_cdomain="$1" _cdomain="$1"
_ckey="$2" _ckey="$2"
_ccert="$3" _ccert="$3"
_cca="$4" _cca="$4"
_cfullchain="$5" _cfullchain="$5"
_cpfx="$6" _cpfx="$6"
_debug _cdomain "$_cdomain" _debug _cdomain "$_cdomain"
_debug _ckey "$_ckey" _debug _ckey "$_ckey"
_debug _ccert "$_ccert" _debug _ccert "$_ccert"
_debug _cca "$_cca" _debug _cca "$_cca"
_debug _cfullchain "$_cfullchain" _debug _cfullchain "$_cfullchain"
_debug _cpfx "$_cpfx" _debug _cpfx "$_cpfx"
DOMAIN_DIR=$_cdomain DOMAIN_DIR=$_cdomain
if echo "$DOMAIN_PATH" | grep -q "$ECC_SUFFIX"; then if echo "$DOMAIN_PATH" | grep -q "$ECC_SUFFIX"; then
DOMAIN_DIR="$DOMAIN_DIR"_ecc DOMAIN_DIR="$DOMAIN_DIR"_ecc
fi fi
_debug2 "DOMAIN_DIR" "$DOMAIN_DIR" _debug2 "DOMAIN_DIR" "$DOMAIN_DIR"
_preprocess_deployfile "$DOMAIN_DIR/$MULTIDEPLOY_FILENAME" _preprocess_deployfile "$DOMAIN_DIR/$MULTIDEPLOY_FILENAME"
MULTIDEPLOY_CONFIG="${MULTIDEPLOY_CONFIG:-$(_getdeployconf MULTIDEPLOY_CONFIG)}" MULTIDEPLOY_CONFIG="${MULTIDEPLOY_CONFIG:-$(_getdeployconf MULTIDEPLOY_CONFIG)}"
if [ -z "$MULTIDEPLOY_CONFIG" ]; then if [ -z "$MULTIDEPLOY_CONFIG" ]; then
MULTIDEPLOY_CONFIG="default" MULTIDEPLOY_CONFIG="default"
_info "MULTIDEPLOY_CONFIG is not set, so I will use 'default'." _info "MULTIDEPLOY_CONFIG is not set, so I will use 'default'."
else else
_savedeployconf "MULTIDEPLOY_CONFIG" "$MULTIDEPLOY_CONFIG" _savedeployconf "MULTIDEPLOY_CONFIG" "$MULTIDEPLOY_CONFIG"
_debug2 "MULTIDEPLOY_CONFIG" "$MULTIDEPLOY_CONFIG" _debug2 "MULTIDEPLOY_CONFIG" "$MULTIDEPLOY_CONFIG"
fi fi
# TODO: Deploy to services # TODO: Deploy to services
} }
#################### Private functions below ##################### #################### Private functions below #####################
# deploy_filepath # deploy_filepath
_preprocess_deployfile() { _preprocess_deployfile() {
deploy_file="$1" deploy_file="$1"
# Check if yq is installed # Check if yq is installed
if ! command -v yq >/dev/null 2>&1; then if ! command -v yq >/dev/null 2>&1; then
_err "yq is not installed! Please install yq and try again." _err "yq is not installed! Please install yq and try again."
return 1 return 1
fi fi
# Check if deploy file exists and create a default template if not # Check if deploy file exists and create a default template if not
if [ -f "$deploy_file" ]; then if [ -f "$deploy_file" ]; then
_debug3 "Deploy file found." _debug3 "Deploy file found."
_check_deployfile "$deploy_file" "$MULTIDEPLOY_CONFIG" _check_deployfile "$deploy_file" "$MULTIDEPLOY_CONFIG"
else else
# TODO: Replace URL with wiki link # TODO: Replace URL with wiki link
_err "Deploy file not found. Go to https://CHANGE_URL_TO_WIKI to see how to create one." _err "Deploy file not found. Go to https://CHANGE_URL_TO_WIKI to see how to create one."
return 1 return 1
fi fi
} }
# deploy_filepath deploy_config # deploy_filepath deploy_config
_check_deployfile() { _check_deployfile() {
deploy_file="$1" deploy_file="$1"
deploy_config="$3" deploy_config="$3"
# Check version # Check version
deploy_file_version=$(yq '.version' "$deploy_file") deploy_file_version=$(yq '.version' "$deploy_file")
if [ "$MULTIDEPLOY_VERSION" != "$deploy_file_version" ]; then if [ "$MULTIDEPLOY_VERSION" != "$deploy_file_version" ]; then
_err "As of $PROJECT_NAME $VER, the deploy file needs version $MULTIDEPLOY_VERSION! Your current deploy file is of version $deploy_file_version." _err "As of $PROJECT_NAME $VER, the deploy file needs version $MULTIDEPLOY_VERSION! Your current deploy file is of version $deploy_file_version."
return 1 return 1
fi
# Check if config exists
if ! yq e ".configs[] | select(.name == \"$deploy_config\")" "$deploy_file" >/dev/null; then
_err "Config '$deploy_config' not found."
return 1
fi
# Extract all services from config
services=$(yq e ".configs[] | select(.name == \"$deploy_config\").services[]" "$deploy_file")
if [ -z "$services" ]; then
_err "Config '$deploy_config' does not have any services to deploy to."
return 1
fi
# Check if extracted services exist in services list
for service in $services; do
if ! yq e ".services[] | select(.name == \"$service\")" "$deploy_file" >/dev/null; then
_err "Service '$service' not found."
return 1
fi fi
# Check if config exists # Check if service has hook
if ! yq e ".configs[] | select(.name == \"$deploy_config\")" "$deploy_file" >/dev/null; then if ! yq e ".services[] | select(.name == \"$service\").hook" "$deploy_file" >/dev/null; then
_err "Config '$deploy_config' not found." _err "Service '$service' does not have a hook."
return 1 return 1
fi fi
# Extract all services from config # Check if service has environment
services=$(yq e ".configs[] | select(.name == \"$deploy_config\").services[]" "$deploy_file") if ! yq e ".services[] | select(.name == \"$service\").environment" "$deploy_file" >/dev/null; then
_err "Service '$service' does not an environment."
if [ -z "$services" ]; then return 1
_err "Config '$deploy_config' does not have any services to deploy to."
return 1
fi fi
done
# Check if extracted services exist in services list
for service in $services; do
if ! yq e ".services[] | select(.name == \"$service\")" "$deploy_file" >/dev/null; then
_err "Service '$service' not found."
return 1
fi
# Check if service has hook
if ! yq e ".services[] | select(.name == \"$service\").hook" "$deploy_file" >/dev/null; then
_err "Service '$service' does not have a hook."
return 1
fi
# Check if service has environment
if ! yq e ".services[] | select(.name == \"$service\").environment" "$deploy_file" >/dev/null; then
_err "Service '$service' does not an environment."
return 1
fi
done
} }

Loading…
Cancel
Save