refcodes-batch.1.0.2.source-code.validate-website-template-config.job Maven / Gradle / Ivy
#!/bin/bash
# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showWebsiteTemplateConfiguration {
echo "The switch \"-j $JOB\" validates all \"WEBSITE_TEMPLATE\ specific " >&2
echo "settings in the CONFIG file. Supported properties in the CONFIG file are: " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "WEBSITE_TEMPLATE = (set 'y' if a website template is used/configured, else 'n') " >&2
echo "WEBSITE_TEMPLATE_DIR = (the path to the files of your template) " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
if [[ $# -eq 1 ]] ; then
showError "$1"
fi
}
# ------------------------------------------------------------------------------
# Missing property:
# $1: The missing property's name (without prepended "$").
# ------------------------------------------------------------------------------
function exitOnMissingWebsiteTemplateProperty {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsiteTemplateProperty\" 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
showWebsiteTemplateConfiguration "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 exitOnMissingWebsiteTemplatePropertyPath {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsiteTemplatePropertyPath\" 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
showWebsiteTemplateConfiguration "Path or file \"$VALUE\" not found defined in property \"$1\" of the \"$CONFIG\" config !!!"
exit $EXIT_ERROR
fi
}
# ------------------------------------------------------------------------------
if [[ $VERBOSE = y ]] ; then
echo "\"WEBSITE\" configuration validation is activated ..." >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $HELP = y ]] ; then
showWebsiteTemplateConfiguration
fi
if [[ $HELP = n ]] ; then
if [[ $VERBOSE = y ]] ; then
showProperty "WEBSITE_TEMPLATE"
showProperty "WEBSITE_TEMPLATE_DIR"
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $WEBSITE_TEMPLATE = y ]] ; then
exitOnMissingWebsiteTemplateProperty "WEBSITE_TEMPLATE_DIR"
fi
showSuccess "\"WEBSITE_TEMPLATE\" configuration for \"$CONFIG\" validated !"
fi