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