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

refcodes-batch.0.3.0.source-code.clone-website-template.job Maven / Gradle / Ivy

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

. $SCRIPT_DIR/lib-filesystem.inc

if [[ $HELP = y ]] ; then
	echo "The switch \"-j $JOB\" uses a given configuration to                            " >&2
	echo "clone a template website with a temaplte DB to a (target) website and DB.       " >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

# . $SCRIPT_DIR/validate-db-template-config.job
. $SCRIPT_DIR/validate-website-config.job
. $SCRIPT_DIR/validate-website-template-config.job
. $SCRIPT_DIR/validate-website-settings-config.job

if [[ $HELP = y ]] ; then
	exit $EXIT_SUCCESS
fi

exitOnConfigOff "DB"
exitOnConfigOff "DB_TEMPLATE"
exitOnConfigOff "WEBSITE"
exitOnConfigOff "WEBSITE_TEMPLATE"
exitOnConfigOff "WEBSITE_SETTINGS"

if [[ $VERBOSE = y ]] ; then
	echo "Cloning website \"$WEBSITE_TEMPLATE_DOMAIN_NAME\" to \"$WEBSITE_DOMAIN_NAME\" ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

. $SCRIPT_DIR/clone-db-template.job

WEBSITE_TEMPLATE_SETTINGS_DIR="$WEBSITE_TEMPLATE_DIR/$WEBSITE_SETTINGS_FILE"
WEBSITE_SETTINGS_DIR="$WEBSITE_DIR/$WEBSITE_SETTINGS_FILE"

if [[ $VERBOSE = y ]] ; then
	echo "Assuming the path \"$WEBSITE_TEMPLATE_SETTINGS_DIR\" to exist ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

exitOnMissingVariablePath "WEBSITE_TEMPLATE_SETTINGS_DIR"

if [[ $VERBOSE = y ]] ; then
	echo "Cloning folder \"$WEBSITE_TEMPLATE_DIR\" to \"$WEBSITE_DIR\" ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

cp -aR $WEBSITE_TEMPLATE_DIR/* $WEBSITE_DIR
exitOnError "Unable to clone website \"$WEBSITE_TEMPLATE_DIR\" to \"$WEBSITE_DIR\" !!!"

if [[ $VERBOSE = y ]] ; then
	echo "Assuming the path \"$WEBSITE_SETTINGS_DIR\" to exist ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

exitOnMissingVariablePath "WEBSITE_SETTINGS_DIR"

if [[ $VERBOSE = y ]] ; then
	echo "Configuring DB for \"$WEBSITE_SETTINGS_DIR\" ..." >&2
	# echo "--------------------------------------------------------------------------------" >&2
	logSeparator
fi

sed -i 's/'$DB_TEMPLATE_NAME'/'$DB_NAME'/g' $WEBSITE_SETTINGS_DIR
sed -i 's/'$DB_TEMPLATE_USER_NAME'/'$DB_USER_NAME'/g' $WEBSITE_SETTINGS_DIR
sed -i 's/'$DB_TEMPLATE_USER_PASSWORD'/'$DB_USER_PASSWORD'/g' $WEBSITE_SETTINGS_DIR

echo " Website clone at \"$WEBSITE_DOMAIN_NAME\" from \"$WEBSITE_TEMPLATE_DIR\" was created:" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator
echo "+ Website clone details see: \"$WEBSITE_DIR\"" >&2
# echo "--------------------------------------------------------------------------------" >&2
logSeparator

showSuccess "Cloned \"$WEBSITE_TEMPLATE_DOMAIN_NAME\" to \"$WEBSITE_DOMAIN_NAME\" !"




© 2015 - 2024 Weber Informatics LLC | Privacy Policy