Created
August 9, 2016 16:59
-
-
Save clowestab/4793ee871881678ec9c623a5d39c6822 to your computer and use it in GitHub Desktop.
A simple script for automatically updating a Ghost blog on an external server.
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
core | |
index.js | |
package.json | |
npm-shrinkwrap.json |
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 | |
START=$(date +%s) | |
STAGEDIR=/Path/ghost-new/ | |
# We will send them to this host | |
HOST=123.456.789 | |
USERNAME=username | |
# This directory on the host | |
HOSTDIR=/home/your-blog | |
COMMANDS_BEFORE="forever stop index.js; rm -rf core; rm -rf node_modules; rm index.js; rm *.md; rm *.json; exit" | |
COMMANDS_AFTER="npm cache clean; npm install --production; NODE_ENV=production forever start index.js; exit" | |
ssh -l ${USERNAME} ${HOST} "${COMMANDS_BEFORE}" | |
rsync -r -a -v -u -e "ssh -l ${USERNAME}" ${STAGEDIR} ${HOST}:${HOSTDIR} --include-from 'include-from-production.txt' --omit-dir-times | |
ssh -l ${USERNAME} ${HOST} "${COMMANDS_AFTER}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment