mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-01-10 17:12:07 +08:00
Fix config file checks
The config file checks were returning okay even when there were errors. The yq tool returns "null" when it cannot find what's queried, but exists with a 0 rc still.
This commit is contained in:
@@ -127,7 +127,7 @@ _preprocess_deployfile() {
|
|||||||
# _check_deployfile "<deploy_file_path>"
|
# _check_deployfile "<deploy_file_path>"
|
||||||
_check_deployfile() {
|
_check_deployfile() {
|
||||||
_deploy_file="$1"
|
_deploy_file="$1"
|
||||||
_debug2 "Deploy file" "$_deploy_file"
|
_debug2 "check: Deploy file" "$_deploy_file"
|
||||||
|
|
||||||
# Check version
|
# Check version
|
||||||
_deploy_file_version=$(yq '.version' "$_deploy_file")
|
_deploy_file_version=$(yq '.version' "$_deploy_file")
|
||||||
@@ -135,38 +135,44 @@ _check_deployfile() {
|
|||||||
_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
|
fi
|
||||||
_debug2 "Deploy file version is compatible: $_deploy_file_version"
|
_debug2 "check: Deploy file version is compatible: $_deploy_file_version"
|
||||||
|
|
||||||
# Extract all services from config
|
# Extract all services from config
|
||||||
_services=$(yq e '.services[].name' "$_deploy_file")
|
_services=$(yq e '.services[].name' "$_deploy_file")
|
||||||
_debug2 "Services" "$_services"
|
|
||||||
|
|
||||||
if [ -z "$_services" ]; then
|
if [ -z "$_services" ]; then
|
||||||
_err "Config does not have any services to deploy to."
|
_err "Config does not have any services to deploy to."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
_debug2 "Config has services."
|
_debug2 "check: Config has services."
|
||||||
|
echo "$_services" | while read -r _service; do
|
||||||
|
_debug3 " - $_service"
|
||||||
|
done
|
||||||
|
|
||||||
# Check if extracted services exist in services list
|
# Check if extracted services exist in services list
|
||||||
echo "$_services" | while read -r _service; do
|
echo "$_services" | while read -r _service; do
|
||||||
_debug2 "Checking service" "$_service"
|
_debug2 "check: Checking service: $_service"
|
||||||
# Check if service exists
|
# Check if service exists
|
||||||
if ! yq e ".services[] | select(.name == \"$_service\")" "$_deploy_file" >/dev/null; then
|
_service_config=$(yq e ".services[] | select(.name == \"$_service\")" "$_deploy_file")
|
||||||
|
if [ -z "$_service_config" ] || [ "$_service_config" = "null" ]; then
|
||||||
_err "Service '$_service' not found."
|
_err "Service '$_service' not found."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_secure_debug3 "check: Service '$_service' configuration" "$_service_config"
|
||||||
|
|
||||||
# Check if service has hook
|
_service_hook=$(echo "$_service_config" | yq e ".hook" -)
|
||||||
if ! yq e ".services[] | select(.name == \"$_service\").hook" "$_deploy_file" >/dev/null; then
|
if [ -z "$_service_hook" ] || [ "$_service_hook" = "null" ]; then
|
||||||
_err "Service '$_service' does not have a hook."
|
_err "Service '$_service' does not have a hook."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_debug3 "check: Service '$_service' hook" "$_service_hook"
|
||||||
|
|
||||||
# Check if service has environment
|
_service_environment=$(echo "$_service_config" | yq e ".environment" -)
|
||||||
if ! yq e ".services[] | select(.name == \"$_service\").environment" "$_deploy_file" >/dev/null; then
|
if [ -z "$_service_environment" ] || [ "$_service_environment" = "null" ]; then
|
||||||
_err "Service '$_service' does not have an environment."
|
_err "Service '$_service' does not have an environment."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_secure_debug3 "check: Service '$_service' environment" "$_service_environment"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user