Created
February 27, 2019 14:33
-
-
Save tobiasdalhof/4f470200d433899b73d1155a02d4c47d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Get environment from first attribute | |
ENV=$1 | |
ENV_DEV="dev" | |
ENV_STAGING="staging" | |
ENV_PROD="prod" | |
MAGENTO_PATH="../magento" | |
HTACCESS_PATH="$MAGENTO_PATH/.htaccess" | |
LOCALXML_PATH="$MAGENTO_PATH/app/etc/local.xml" | |
AMFPCLOCALXML_PATH="$MAGENTO_PATH/app/etc/z_amfpclocal.xml" | |
# Check user input | |
if [ "$ENV" != "$ENV_DEV" ] && [ "$ENV" != "$ENV_STAGING" ] && [ "$ENV" != "$ENV_PROD" ] | |
then | |
echo "First attribute must be '$ENV_DEV', '$ENV_STAGING' or '$ENV_PROD'" | |
exit 1 | |
fi | |
echo "Deploying config files for '$ENV' environment" | |
echo "========================================================================" | |
function deployFile { | |
FILE=$1 | |
# Example: ./magento/app/etc/local.xml.prod | |
TEMPLATE="$FILE.$ENV" | |
# Check config template file | |
if [ -e "$TEMPLATE" ] | |
then | |
echo "$TEMPLATE exists" | |
else | |
echo "ERR: $TEMPLATE does not exist" | |
exit 1 | |
fi | |
# Remove original file | |
if [ -e "$FILE" ] | |
then | |
echo "Remove $FILE" | |
rm $FILE | |
fi | |
# Use template as original file | |
echo "Copy $TEMPLATE to $FILE" | |
cp $TEMPLATE $FILE | |
} | |
deployFile "$LOCALXML_PATH" | |
echo "========================================================================" | |
deployFile "$HTACCESS_PATH" | |
echo "========================================================================" | |
deployFile "$AMFPCLOCALXML_PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment