refcodes-batch.0.3.0.source-code.validate-website-config.job Maven / Gradle / Ivy
#!/bin/bash
# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showWebsiteConfiguration {
echo "The switch \"-j $JOB\" validates all \"WEBSITE\" specific " >&2
echo "settings in the CONFIG file. Supported properties in the CONFIG file are: " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "WEBSITE = (set 'y' if a site is used/configured, else 'n') " >&2
echo "WEBSITE_DOMAIN_NAME = (the fully qualified domain name of the website to be configured)" >&2
echo "WEBSITE_DIR = (the path to the HTDOCS files of your domain) " >&2
echo "WEBSITE_FS_USER = (the user for file system access on your HTDOCS) " >&2
echo "WEBSITE_FS_GROUP = (the group for file system access on your HTDOCS) " >&2
echo "WEBSITE_LOGS_DIR = (the path for the logfiles of vhost for your domain) " >&2
echo "WEBSITE_SERVER_ADMIN_EMAIL = (the server admin email as in the vhost configuration)" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
if [[ $# -eq 1 ]] ; then
showError "$1"
fi
}
# ------------------------------------------------------------------------------
# Missing property:
# $1: The missing property's name (without prepended "$").
# ------------------------------------------------------------------------------
function exitOnMissingWebsiteProperty {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsiteProperty\" 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
showWebsiteConfiguration "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 exitOnMissingWebsitePropertyPath {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingWebsitePropertyPath\" 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
showWebsiteConfiguration "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
showWebsiteConfiguration
fi
if [[ $HELP = n ]] ; then
if [[ $VERBOSE = y ]] ; then
showProperty "WEBSITE"
showProperty "WEBSITE_DOMAIN_NAME"
showProperty "WEBSITE_DIR"
showProperty "WEBSITE_FS_USER"
showProperty "WEBSITE_FS_GROUP"
showProperty "WEBSITE_LOGS_DIR"
showProperty "WEBSITE_SERVER_ADMIN_EMAIL"
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $WEBSITE = y ]] ; then
exitOnMissingWebsiteProperty "WEBSITE_DOMAIN_NAME"
warnOnMissingVariable "TLL" "the third-level-label of the \"WEBSITE_DOMAIN_NAME\" property"
warnOnMissingVariable "SLL" "the sencond-level-label of the \"WEBSITE_DOMAIN_NAME\" property"
warnOnMissingVariable "TLD" "the third-level-label of the \"WEBSITE_DOMAIN_NAME\" property"
exitOnMissingWebsiteProperty "WEBSITE_DIR"
exitOnMissingWebsiteProperty "WEBSITE_FS_USER"
exitOnMissingWebsiteProperty "WEBSITE_FS_GROUP"
exitOnMissingWebsiteProperty "WEBSITE_LOGS_DIR"
exitOnMissingWebsiteProperty "WEBSITE_SERVER_ADMIN_EMAIL"
fi
showSuccess "\"WEBSITE\" configuration for \"$CONFIG\" validated !"
fi