-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy
executable file
·81 lines (68 loc) · 2.22 KB
/
deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# This shell supports quick deployment of dubbo web services
# Assume the system has installed the following dependencies:
#
# ---------------------------------------------------------
# jekyll | https://jekyllrb.com/docs/home/
# ---------------------------------------------------------
# gitbook | http://www.jianshu.com/p/ec1e7d2c76c6
# ---------------------------------------------------------
# pages-gem | https://github.com/github/pages-gem
# ---------------------------------------------------------
#
# email : zonghai.szh@alibaba-inc.com
# date : 2017-11-27 21:07:00
# Local Server Port for aliyun
port=8000
# Local Server Host
host=0.0.0.0
script_dir=$(cd `dirname $0`; pwd)
base_dir=`dirname ${script_dir}`
parent_dir=`dirname ${base_dir}`
git_book_dir="${parent_dir}/dubbo-docs"
saved_dir=${git_book_dir}
if [ -d ${git_book_dir} ]
then
echo "updating '${base_dir}'"
# update self code
git pull
# ready to update git books
echo "updating '${git_book_dir}'"
cd ${git_book_dir}
git pull
else
echo "Attempting to create the directory '${git_book_dir}'"
cd ${parent_dir}
# clone github code for books
echo "git clone $git_book_url"
git clone https://github.com/dubbo/dubbo-docs.git
cd ${base_dir}
# first time , we should install jekyll dependency plugin
echo "run 'bundle install' for '${base_dir}'."
bundle install
fi
for book_dir in ${git_book_dir}/*
do
if [ -d ${book_dir} ]
then
echo "run 'gitbook build' for '${book_dir}'."
gitbook build ${book_dir}
echo "build done."
to_dir_name=$(echo ${book_dir} | awk -F \/ '{print $NF}');
to_dir_path="${base_dir}/books/${to_dir_name}";
echo "copying '${book_dir}/_book/ to ${to_dir_path}."
if [ ! -e "${to_dir_path}" ]
then
mkdir -p ${to_dir_path}
fi
cp -rf "${book_dir}/_book/." ${to_dir_path}
echo "copy done."
fi
done
# I'm ready to compile and start service
cd ${base_dir}
echo "run 'jekyll build --config _config_build.yml' for '${saved_dir}'"
bundle exec jekyll build --config _config_build.yml
# Now, start jekyll server
cd ${base_dir}
bundle exec jekyll server --port ${port} --host ${host} --detach