All Downloads are FREE. Search and download functionalities are using the official Maven repository.

refcodes-batch.1.0.2.source-code.validate-folder-template-config.job Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
#!/bin/bash

# -----------------------------------------------------------------------------
# Shows the according config:
# -----------------------------------------------------------------------------
function showFolderTemplateConfiguration {
	echo "The switch \"-j $JOB\" validates all \"FOLDER_TEMPLATE\ specific                " >&2
	echo "settings in the CONFIG file. Supported properties in the CONFIG file are:       " >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
	echo "FOLDER_TEMPLATE = (set 'y' if a folder template is used/configured, else 'n')   " >&2
	echo "FOLDER_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 exitOnMissingFolderTemplateProperty {
	if [ -z "$1" ] ; then
		showError "Argument missing: The function \"exitOnMissingFolderTemplateProperty\" 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
		showFolderTemplateConfiguration "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 exitOnMissingFolderTemplatePropertyPath {
	if [ -z "$1" ] ; then
		showError "Argument missing: The function \"exitOnMissingFolderTemplatePropertyPath\" 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
		showFolderTemplateConfiguration "Path or file \"$VALUE\" not found defined in property \"$1\" of the \"$CONFIG\" config !!!"
		exit $EXIT_ERROR
	fi
}

# -----------------------------------------------------------------------------

if [[ $VERBOSE = y ]] ; then
	echo "\"FOLDER\" configuration validation is activated ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

if [[ $HELP = y ]] ; then
	showFolderTemplateConfiguration 
fi

if [[ $HELP = n ]] ; then
	if [[ $VERBOSE = y ]] ; then
		showProperty "FOLDER_TEMPLATE"
		showProperty "FOLDER_TEMPLATE_DIR"
		# echo "--------------------------------------------------------------------------------" >&2
		logSeparator
	fi

	if [[ $FOLDER_TEMPLATE = y ]] ; then
		exitOnMissingFolderTemplateProperty "FOLDER_TEMPLATE_DIR"
	fi

	showSuccess "\"FOLDER_TEMPLATE\" configuration for \"$CONFIG\" validated !"
fi




© 2015 - 2024 Weber Informatics LLC | Privacy Policy