-
Notifications
You must be signed in to change notification settings - Fork 22
/
update.sh
executable file
·122 lines (112 loc) · 2.89 KB
/
update.sh
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/zsh
base_dir=$(cd "$(dirname "$0")" && pwd)
: ${RUBY:=ruby}
bitclust_dir=$($RUBY -rrubygems -e 'print Gem::Specification.find_by_name("bitclust-core").gem_dir')
doctree_dir=${base_dir}/../doctree
PATH=${base_dir}/local/bin:$PATH
update_rurema=yes
update_index=yes
reset_index=no
reset_suggest=no
load_data=yes
clear_cache=yes
for argument in $*; do
case "$argument" in
"--no-update-rurema")
update_rurema=no
;;
"--no-update-index")
update_index=no
;;
"--reset-index")
reset_index=yes
;;
"--reset-suggest")
reset_suggest=yes
;;
"--no-load-data")
load_data=no
;;
"--no-clear-cache")
clear_cache=no
;;
esac
done
update_rurema()
{
local version=$1
nice ${RUBY} \
-I ${base_dir}/lib \
-I ${bitclust_dir}/lib \
${base_dir}/bin/rurema-search-bitclust \
--database ${base_dir}/db-${version} \
init encoding=utf-8 version=${version}
nice ${RUBY} \
-I ${base_dir}/lib \
-I ${bitclust_dir}/lib \
${base_dir}/bin/rurema-search-bitclust \
--database ${base_dir}/db-${version} \
update --stdlibtree ${doctree_dir}/refm/api/src
nice ${RUBY} \
-I ${base_dir}/lib \
-I ${bitclust_dir}/lib \
${base_dir}/bin/rurema-search-bitclust \
--database ${base_dir}/db-${version} \
--capi \
update ${doctree_dir}/refm/capi/src/**/*.rd
rm -rf ${base_dir}/public/${version}.{old,new}
nice ${RUBY} \
-I ${base_dir}/lib \
-I ${bitclust_dir}/lib \
${base_dir}/bin/rurema-search-bitclust \
--database ${base_dir}/db-${version} \
statichtml \
--quiet \
--no-stop-on-syntax-error \
--fs-casesensitive \
--outputdir ${base_dir}/public/${version}.new \
--catalog ${bitclust_dir}/data/bitclust/catalog \
--template ${bitclust_dir}/data/bitclust/template
if [ $? -eq 0 ]; then
mv ${base_dir}/public/${version}{,.old}
mv ${base_dir}/public/${version}{.new,}
rm -rf ${base_dir}/public/${version}.old
fi
}
if [ "$update_rurema" = "yes" ]; then
if [ -d ${doctree_dir} ]; then
(cd ${doctree_dir} && git pull --rebase)
else
git clone https://github.com/rurema/doctree.git ${doctree_dir}
fi
for version in 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 3.0 3.1 3.2 3.3; do
update_rurema $version
done
wait
fi
if [ "$update_index" = "yes" ]; then
reset_argument=
load_data_argument=
if [ "$reset_index" = "yes" ]; then
rm -rf ${base_dir}/groonga-database
rm -rf ${base_dir}/var/lib/suggest
touch ${base_dir}/tmp/restart.txt
reset_argument="--reset"
fi
if [ "$reset_suggest" = "yes" ]; then
rm -rf ${base_dir}/var/lib/suggest
touch ${base_dir}/tmp/restart.txt
fi
if [ "$load_data" != "yes" ]; then
load_data_argument="--no-load-data"
fi
nice ${RUBY} \
${base_dir}/bin/bitclust-indexer \
${reset_argument} \
${load_data_argument} \
${base_dir}/db-*
fi
if [ "$clear_cache" = "yes" ]; then
nice ${RUBY} ${base_dir}/bin/rurema-search-clear-cache
fi
touch ${base_dir}/tmp/restart.txt