refcodes-batch.1.0.2.source-code.validate-website-settings-config.job Maven / Gradle / Ivy
#!/bin/bash
# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showWebsiteSettingsConfiguration {
echo "The switch \"-j $JOB\" validates all \"WEBSITE_SETTINGS\" specific " >&2
echo "settings in the CONFIG file. Supported properties in the CONFIG file are: " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "WEBSITE_SETTINGS = (set 'y' if a site is providing a settings file, else 'n') " >&2
echo "WEBSITE_SETTINGS_FILE = (the path relative to the WEBSITE_DIR of the file containing the DB configuration for the website)" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
if [[ $# -eq 1 ]] ; then
showError "$1"
fi
}
# ------------------------------------------------------------------------------
# Missing property:
# $1: The missing property's name (without prepended "$").
# ------------------------------------------------------------------------------
function exitOnMissingWebsiteSettingsProperty {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsiteSettingsProperty\" expects an argument !!!" >&2
exit $EXIT_BUG
fi
# $VALUE is the value of the variable passed as $1:
eval "VALUE=\$$1"
if [ -z "$VALUE" ] ; then
showWebsiteSettingsConfiguration "Missing or empty property \"$1\" !!!"
exit $EXIT_ERROR
fi
}
# ------------------------------------------------------------------------------
# File defined in $CONFIG_FILE non exisiting:
# $1 The property name (without prepended "$") with the (non exisitent) path.
# ------------------------------------------------------------------------------
function exitOnMissingWebsiteSettingsPropertyPath {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsiteSettingsPropertyPath\" expects an argument !!!" >&2
exit $EXIT_BUG
fi
# $VALUE is the value of the variable passed as $1:
eval "VALUE=\$$1"
if [ ! -e "$VALUE" ] && [ ! -L "$VALUE" ] ; then
showWebsiteSettingsConfiguration "Path or file \"$VALUE\" not found defined in property \"$1\" of the \"$CONFIG\" config !!!"
exit $EXIT_ERROR
fi
}
# -----------------------------------------------------------------------------
if [[ $VERBOSE = y ]] ; then
echo "\"WEBSITE_SETTINGS\" configuration validation is activated ..." >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $HELP = y ]] ; then
showWebsiteSettingsConfiguration
fi
if [[ $HELP = n ]] ; then
if [[ $VERBOSE = y ]] ; then
showProperty "WEBSITE_SETTINGS"
showProperty "WEBSITE_SETTINGS_FILE"
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $WEBSITE_SETTINGS = y ]] ; then
exitOnMissingWebsiteSettingsProperty "WEBSITE_SETTINGS_FILE"
fi
showSuccess "\"WEBSITE_SETTINGS\" configuration for \"$CONFIG\" validated !"
fi