Ghost upgrade to 0.5.2
Posted
不小心看到更新了,所以就去更新了(确实有新功能,如侧边栏和主题图片等,默认模板的字体也有修改),结果掉到自己给自己挖的坑里面去了。。。(手贱是病不治不行啊。。。)
参考How to upgrade self-installed Ghost来升级即可。不过我又加上了修改fonts来源(通过sed),并修改excerpt(也是通过sed。。。)
由于Ghost用的sqlite是不加密的(还是因为我用的是dev版本?),所以sed替换的时候会把sqlite数据库(content/data/sqlite-dev)里面的数据一并替换掉(还记得我之前写过Ghost访问比Wordpress还慢?么?真是自掘坟墓啊)
结果启动Ghost就报sql corruption 500的错误。。。(这么“写”数据,基本的MD5校验都过不了啊)
真是一失足成千古恨啊。折腾了蛮久才发现是这个问题。 T_T
附上修改后的脚本,运行
sudo ./upgrade_ghost.sh TARGET_DIR_PATH
```即可:
```language-bash
#stop all
echo '1. stop all -----------------'
forever stopall
#download latest build
echo '2. download latest package -------------------'
rm ghost-latest.zip
wget http://ghost.org/zip/ghost-latest.zip
#rm core
echo '3. delete core dir ---------------'
rm -rf $1/core
#unzip
echo '4. unzip and merge code ----------------'
unzip -uo ghost-latest.zip -d $1/
#install
rm ghost-latest.zip
cd $1/
echo '5. install package ----------------'
npm install --production
#change fontapis..
#if visiting fonts.googleapis.com cost too much time, try following codes.
echo '6. replace fonts api ---------------'
sed -i "s/fonts.googleapis.com/fonts.useso.com/g" `grep fonts.googleapis.com -rl ./content/themes/`
sed -i "s/fonts.googleapis.com/fonts.useso.com/g" `grep fonts.googleapis.com -rl ./core/server/views/`
#change post page what to show...
#Want to show formatted html contents at home page, try following codes.
echo '7. replace "excerpt" with "content" ---------------'
sed -i "s#<p>{{excerpt words=\"26\"}} <a class=\"read-more\" href=\"{{url}}\">»#<p>{{content words=\"32\"}} <a class=\"read-more\" href=\"{{url}}\">\»\»#g" ./content/themes/casper/partials/loop.hbs
#restart
echo '8. restart ---------------'
~/start_ghost.sh
echo ' ------------ All done. --------------'
不出意外这样就升级完啦~
Tada~