#!/bin/sh
echo "$USER"
IS_BARE=$(git rev-parse --is-bare-repository)
if [ -z "$IS_BARE" ]; then
echo >&2 "fatal: post-receive: IS_NOT_BARE"
exit 1
fi
unset GIT_DIR
DeployPath="/Data/www/java_guide"
echo "==============================================="
cd $DeployPath
echo "deploying the test web"
#git stash
#git pull origin master
echo "$USER"
expect -c "
set timeout 5;
spawn git pull;
expect {
"Username" { send \"username\r\"; exp_continue }
"Password" { send \"123456\r\" }
};
expect eof;
spawn gitbook build;
expect "success";
expect eof;
"
echo "$USER"
sleep 10
time=`date`
echo "web server pull at webserver at time: $time."
echo "================================================"
Username for 'http://git.domain.dev': username
Password for 'http://username@git.domain.dev':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 372 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: www-data
remote: ===============================================
remote: deploying the test web
remote: www-data
remote: spawn git pull
remote: Username for 'http://git.domain.dev': username
remote: Password for 'http://username@git.domain.dev':
remote: spawn gitbook build
remote: /usr/local/lib/node_modules/gitbook-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:41
remote: if (!stat.isDirectory()) throw err0
remote: ^
remote:
remote: Error: EEXIST: file already exists, mkdir '/var/www/.gitbook'
remote: at Error (native)
remote: at Object.fs.mkdirSync (fs.js:794:18)
remote: at Object.mkdirsSync (/usr/local/lib/node_modules/gitbook-cli/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:22:9)
remote: at Object.init (/usr/local/lib/node_modules/gitbook-cli/lib/config.js:21:8)
remote: at Object.<anonymous> (/usr/local/lib/node_modules/gitbook-cli/bin/gitbook.js:36:9)
remote: at Module._compile (module.js:410:26)
remote: at Object.Module._extensions..js (module.js:417:10)
remote: at Module.load (module.js:344:32)
remote: at Function.Module._load (module.js:301:12)
remote: at Function.Module.runMain (module.js:442:10)
remote: expect: spawn id exp7 not open
remote: while executing
remote: "expect eof"
remote: www-data
remote: web server pull at webserver at time: 2016 年 12 月 28 日 星期三 16:54:08 CST.
remote: ================================================
To http://git.domain.dev/java_guide.git
b44864b..42e4c63 master -> master
pull
没有成功,gitbook build
也没有成功。sudo -u www-data ./post-receive
www-data
===============================================
deploying the test web
www-data
spawn git pull
Username for 'http://git.domain.dev': username
Password for 'http://username@git.domain.dev':
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
展开对象中: 100% (3/3), 完成.
来自 http://git.domain.dev/java_guide
b44864b..42e4c63 master -> origin/master
更新 b44864b..42e4c63
warning: 不能访问 '/home/user/.config/git/attributes':权限不够
warning: 不能访问 '/home/user/.config/git/ignore':权限不够
warning: 不能访问 '/home/user/.config/git/attributes':权限不够
Fast-forward
warning: 不能访问 '/home/user/.config/git/attributes':权限不够
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
spawn gitbook build
info: 7 plugins are installed
info: 6 explicitly listed
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 17 pages
info: found 1 asset files
info: >> generation finished with success in 2.1s !
www-data
web server pull at webserver at time: 2016 年 12 月 28 日 星期三 17:02:04 CST.
================================================
pull
和gitbook build
都成功了。用的 nginx ,版本 1.10.0 ( Ubuntu ),确认了 nginx 的权限是www-data
,
Git
版本 2.7.4 ,
GitBook 版本 3.2.2 ,
nodejs 版本 4.2.6 ,
npm 版本 3.5.2
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.