refcodes-batch.0.3.0.source-code.validate-typo3-config.job Maven / Gradle / Ivy
#!/bin/bash
# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showTypo3Configuration {
echo "The switch \"-j $JOB\" validates all \"TYPO3\" specific " >&2
echo "settings in the CONFIG file. Supported properties in the CONFIG file are: " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "TYPO3 = (set to 'y' if we have a Typo3 based site, else 'n') " >&2
echo "TYPO3_DIR = (the path to your Typo3 installation) " >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
if [[ $# -eq 1 ]] ; then
showError "$1"
fi
}
# ------------------------------------------------------------------------------
# Missing property:
# $1: The missing property's name (without prepended "$").
# ------------------------------------------------------------------------------
function exitOnMissingTypo3Property {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingTypo3Property\" 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
showTypo3Configuration "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 exitOnMissingTypo3PropertyPath {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"exitOnMissingTypo3PropertyPath\" 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
showTypo3Configuration "Path or file \"$VALUE\" not found defined in property \"$1\" of the \"$CONFIG\" config !!!"
exit $EXIT_ERROR
fi
}
# -----------------------------------------------------------------------------
if [[ $VERBOSE = y ]] ; then
echo "\"TYPO3\" configuration validation is activated ..." >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $HELP = y ]] ; then
showTypo3Configuration
fi
if [[ $HELP = n ]] ; then
if [[ $VERBOSE = y ]] ; then
showProperty "TYPO3"
showProperty "TYPO3_DIR"
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
fi
if [[ $TYPO3 = y ]] ; then
exitOnMissingTypo3Property "TYPO3_DIR"
exitOnMissingTypo3PropertyPath "TYPO3_DIR"
fi
if [[ $WEBSITE = n ]] ; then
if [[ $TYPO3 = y ]] ; then
showTypo3Configuration "Setting \"TYPO3=y\") not possible whilst \"WEBSITE=n\" !!!"
exit $EXIT_ERROR
fi
fi
showSuccess "\"TYPO3\" configuration for \"$CONFIG\" validated !"
fi