Created
June 27, 2016 01:43
-
-
Save gkrizek/fe01c90ffac13c56138f6c512ad3682d to your computer and use it in GitHub Desktop.
Script to deploy a Meteor application. Requires the Client side script as well. See: https://blog.gitrandom.com
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 | |
### | |
# Script to Deploy Meteor App to server | |
# This has a counterpart on the client, which is what calls this script to run | |
# If you need help with the Cloudflare API, check their docs | |
### | |
# create by Graham Krizek on March 28, 2016 | |
### | |
# | |
APP_NAME="APPNAME" | |
ROOT="/var/www/$APP_NAME" | |
HOME="/home/gkrizek" | |
#Cloudflare Zone | |
ZONE="ZONE-ID" | |
#Cloudflare Email | |
EMAIL="email@example.com" | |
#Cloudflare API Key | |
APIKEY="API-KEY" | |
RSYNC="$(which rsync)" | |
if [ -a $RSYNC ] | |
then | |
echo " " | |
else | |
sudo yum install -y rsync | |
fi | |
if [ -e "$HOME/$APP_NAME.tar.gz" ] | |
then | |
echo "UNPACKING THE TARBALL" | |
sudo tar -zxvf $HOME/$APP_NAME.tar.gz | |
else | |
echo "$HOME/$APP_NAME.tar.gz does not exist. Make sure the tarball made it to the server ok." | |
exit | |
fi | |
echo "MOVING TO THE WEB ROOT" | |
sudo rsync -a $HOME/bundle $ROOT/ | |
sudo chown -R LINUX-NODE-USER:LINUX-NODE-USER $ROOT | |
echo "RESTART SERVICE" | |
sudo /etc/init.d/init-script restart | |
sudo rm -rf $HOME/bundle | |
sudo rm -rf $HOME/$APP_NAME.tar.gz | |
echo "CLEARING CLOUDFLARE CACHE" | |
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE/purge_cache" \ | |
-H "X-Auth-Email: $EMAIL" \ | |
-H "X-Auth-Key: $APIKEY" \ | |
-H "Content-Type: application/json" \ | |
--data '{"purge_everything":true}' | |
echo " " | |
#Change 'Production' to which ever server this is on | |
echo "SUCCESSFULLY DEPLOYED TO PRODUCTION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment