refcodes-batch.1.0.2.source-code.validate-apache2-config.job Maven / Gradle / Ivy
#!/bin/bash
# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showApache2Configuration {
echo "The switch \"-j $JOB\" validates all \"APACHE2\" specific " >&2
echo "settings in the CONFIG file. Supported properties in the CONFIG file are: " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "APACHE2 = (set to 'y' if we have a Apache2 based site, else 'n') " >&2
echo "APACHE2_DIR = (the path to your Apache2 installation) " >&2
echo "APACHE2_SSL = (set to 'y' in case you want to use \"HTTP\" SSL encryption) " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
if [[ $# -eq 1 ]] ; then
showError "$1"
fi
}
# ------------------------------------------------------------------------------
# Missing property:
# $1: The missing property's name (without prepended "$").
# ------------------------------------------------------------------------------
function exitOnMissingApache2Property {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingApache2Property\" 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
showApache2Configuration "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 exitOnMissingApache2PropertyPath {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingApache2PropertyPath\" 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
showApache2Configuration "Path or file \"$VALUE\" not found defined in property \"$1\" of the \"$CONFIG\" config !!!"
exit $EXIT_ERROR
fi
}
# ------------------------------------------------------------------------------
if [[ $VERBOSE = y ]] ; then
echo "\"APACHE2\" configuration validation is activated ..." >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $HELP = y ]] ; then
showApache2Configuration
fi
if [[ $HELP = n ]] ; then
if [[ $VERBOSE = y ]] ; then
showProperty "APACHE2"
showProperty "APACHE2_DIR"
showProperty "APACHE2_SSL"
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $APACHE2 = y ]] ; then
exitOnMissingApache2Property "APACHE2_DIR"
exitOnMissingApache2PropertyPath "APACHE2_DIR"
fi
showSuccess "\"APACHE2\" configuration for \"$CONFIG\" validated !"
fi