用blog每次提交的时候总是好麻烦,于是就写了个脚本,
用来自动提交源码到source分支,同时更新blog。
该脚本支持preview和git commit message参数,参数分别为-p, -m message
#!/usr/bin/bash
#Autor:Jonathan
#Version:1.0
CommitMes="autocommit"
WorkDir=/home/li/Octopress
IsPreview=0
#添加Ruby配置
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
#处理输入参数
while getopts :m:p opt
do
case "$opt" in
m) CommitMes=$OPTARG;;
p) IsPreview=1;;
*) echo "Unknown option: $opt";;
esac
done
#切换至工作目录
cd $WorkDir
echo "切换至工作目录$WorkDir"
if [ $IsPreview -eq 0 ]
then
#Git提交源码
git add -A .
echo "git add -A ."
git commit -m $CommitMes
echo "git commit -m $CommitMes"
git push origin source
echo "git push"
echo 提交源码完毕
fi
#更新Blog
echo 开始更新Blog
rake generate
echo "rake generate"
if [ $IsPreview -eq 0 ]
then
rake deploy
echo "rake deploy"
else
echo "rake preview, open webbroswer at the url: localhost:4000"
rake preview
fi
echo 更新完毕^.^