Skip to content

Instantly share code, notes, and snippets.

@clowestab
Created August 9, 2016 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clowestab/4793ee871881678ec9c623a5d39c6822 to your computer and use it in GitHub Desktop.
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.
core
index.js
package.json
npm-shrinkwrap.json
#!/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