Created
April 20, 2016 05:43
-
-
Save jewei/1578c323ca3fea910aa4d0afaf0105a1 to your computer and use it in GitHub Desktop.
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 | |
# Written by Jewei Mak <jewei.mak@gmail.com> for Digital Ocean Ghost (one-click-install) to the latest version. | |
# Stop Ghost. | |
service ghost stop | |
# Goto working dir. | |
cd /var/www/ghost | |
# Backup database. | |
for file in /var/www/ghost/content/data/*.db; | |
do cp "$file" "${file}-backup-`date +%Y%m%d`"; | |
done | |
# Clear dir and file. | |
rm -rf /var/www/ghost/ghost-temp /var/www/ghost/ghost-latest.zip /var/www/ghost/latest.zip | |
# Get lastest package. | |
curl -o /var/www/ghost/latest.zip -Lk https://ghost.org/zip/ghost-latest.zip | |
unzip /var/www/ghost/latest.zip -d /var/www/ghost/ghost-temp | |
# Remove the core directory completely. | |
rm -rf /var/www/ghost/core | |
# Copy the new files over. | |
yes | cp -R /var/www/ghost/ghost-temp/core /var/www/ghost | |
yes | cp /var/www/ghost/ghost-temp/*.js /var/www/ghost | |
yes | cp /var/www/ghost/ghost-temp/*.json /var/www/ghost | |
yes | cp /var/www/ghost/ghost-temp/*.md /var/www/ghost | |
yes | cp -R /var/www/ghost/content/themes/casper /var/www/ghost/content/themes | |
# Delete temp folder. | |
rm -rf /var/www/ghost/ghost-temp /var/www/ghost/latest.zip | |
# Set permissions. | |
chown -R ghost:ghost /var/www/ghost | |
# Upgrade dependencies: | |
npm install --production | |
# Start Ghost. | |
service restart ghost | |
echo "Ghost started." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment