Created
July 16, 2014 18:55
-
-
Save colby/b324ff13b96d03e37976 to your computer and use it in GitHub Desktop.
Simple deploy script
This file contains 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
#!/bin/bash | |
usage() | |
{ | |
cat << EOF | |
usage: $0 ENV OPTIONS | |
This script will deploy to the host host. | |
ENVIRONMENTS: | |
staging | |
production | |
OPTIONS: | |
-h Show this message | |
-i Import the database dump | |
EOF | |
} | |
while getopts "hie:" OPTION | |
do | |
case $OPTION in | |
h) | |
usage | |
exit | |
;; | |
e) | |
ENV=$OPTARG | |
;; | |
i) | |
IMPORT=1 | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac | |
done | |
case ${ENV} in | |
staging) | |
ssh -T [email protected] << EOF | |
cd /var/www/host/ | |
git checkout staging | |
git reset --hard | |
git pull origin staging | |
sudo ./scripts/ee-permissions-fix.sh | |
sudo service php5-fpm restart | |
EOF | |
if [[ ${IMPORT} ]]; then | |
ssh -T [email protected] 'mysql -u root -p123 staging < /var/www/host/database-backup/dump.sql' | |
echo "Database has been successfully imported" | |
fi | |
;; | |
production) | |
_ | |
;; | |
*) | |
echo "$0": requires an environment -- e | |
usage | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment