Ghost Blog Update Script

in IT

A basic sh script to update Ghost blog.

This script is written for use in FreeBSD 10.x, and MAY be good for other BSDs and Mac OS X as well. It can also be used for other Unix-like system(such as Linux) with proper modification.

This script assumes:
1. You use system service(rc) to manage your ghost server, and have stop and start as rc commands for halting and launching ghost server. If you don’t know how to do so, read section 5 of this article.
2. Your ghost software is installed in /var/www/ghost
Otherwise, some modifications may be needed before run this script.

Not suitable for version jump update.

# Copyright (c) 2016 Mo Zhang
# Licensed under the MIT License.

#! /bin/sh
service ghost stop  
cd /var/www  
cp -R ghost ghost_backup  
rm ghost-latest.zip  
curl -LOk https://ghost.org/zip/ghost-latest.zip  
unzip ghost-latest.zip -d ghost_new  
cd ghost  
rm -R core  
rm index.js  
rm *.md  
rm *.json  
cp -R ../ghost_new/core .  
cp ../ghost_new/index.js .  
cp ../ghost_new/*.json .  
cp ../ghost_new/*.md .  
cp -R ../ghost_new/content/themes/casper ./content/themes  
cd ..  
chown -R ghost:ghost *  
cd ghost  
npm install --production  
service ghost start