introduction

gitbook好是好,就是需要本地编译,或者直接使用gitbook官方服务。

对于自己编译,琢磨了一个小的可以定时checkout代码并在有变动的时候进行自动编译和更新的小脚本。

checkout and compile and upload

#!/bin/bash

# just pull and get the return code from git pull command
result=`git pull`

# if this command show up to date, so we are exit , else, continue
[[ $result = "Already up-to-date." ]] && exit 0 || echo "Git文件已更新"

# build the book to the dir ../
source ~/.bashrc
gitbook build ./ ../html/

# upload the files to remote server
#scp -r ../html/* root@xxx:/www/webapps/book.opschina.org/
# 换成了rsync,因为如果是scp的话,一个一个文件拷贝覆盖太慢了。
rsync -avzP ../html/* root@xxx:/www/webapps/book.opschina.org/

cron job

    # book.opschina.org
    */5 * * * * cd /opt/gitbook/snowbearopjournal && ./build.sh
Copyright © opschina.org 2017 with zzlyzq@gmail.com all right reserved,powered by Gitbook该文件修订时间: 2017-07-11 11:32:48

results matching ""

    No results matching ""