This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
forked from wikireader/wikireader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00run.sh
166 lines (137 loc) · 3.37 KB
/
00run.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
xml="xml-file-samples/license.xml xml-file-samples/terms.xml enwiki-20090909-pages-articles.xml"
ERROR()
{
echo error: $*
exit 1
}
USAGE()
{
[ -z "$1" ] || echo error: $*
echo usage: $(basename "$0") '<options>' command
echo ' --help -h this message'
echo ' --verbose -v more messages'
echo ' --get-index=n -g <n> where to rsync the pickles from [1 => render1]'
echo ' --host=name -o <name> name of the host [render]'
echo ' --index-only -i only do the index'
echo ' --no-run -n do not run final make'
echo ' --sequential -s run rensering in series'
echo ' --clear -c clear work and dest dirs'
echo ' --work=dir -w <dir> workdir [work]'
echo ' --dest=dir -d <dir> destdir [image]'
exit 1
}
verbose=no
host=render
index=
clear=no
work=work
dest=image
run=yes
seq=no
IndexOnly=no
debug=
args=$(getopt -o hvg:o:p:inscw:d: --long=help,verbose,get-index:,host:,index-only,no-run,sequential,clear,work:,dest:,debug -- "$@") ||exit 1
# replace the arguments with the parsed values
eval set -- "${args}"
while :
do
case "$1" in
-v|--verbose)
verbose=yes
shift
;;
-g|--get-index)
index=$2
shift 2
;;
-o|--host)
host=$2
shift 2
;;
-i|--index-only)
IndexOnly=yes
shift
;;
-n|--no-run)
run=no
shift
;;
-s|--sequential)
seq=yes
shift
;;
-c|--clear)
clear=yes
shift
;;
-w|--work)
work=$2
shift 2
;;
-d|--dest)
dest=$2
shift 2
;;
--debug)
debug=echo
shift
;;
--)
shift
break
;;
-h|--help)
USAGE
;;
*)
USAGE invalid option: $1
;;
esac
done
this_host=$(hostname --short)
this_id=${this_host##${host}}
[ X"${this_id}" = X"${this_host}" ] && this_id=0
farm="farm${this_id}"
eval ${debug} "mkdir -p '${work}'"
eval ${debug} "mkdir -p '${dest}'"
case "${clear}" in
[yY]|[yY][eE][sS])
eval ${debug} "time make clean-index DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
eval ${debug} "time make '${farm}-clean' DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
eval ${debug} "rm -f '${work}'/* '${dest}'/*"
;;
esac
# update
git pull --rebase
# copy the index from another machine
if [ -n "${index}" ]
then
list='articles.pickle offsets.pickle counts.text'
items=
for i in ${list}
do
items="${items} ${host}${index}:samo/${work}/${i}"
done
eval ${debug} "rsync -avHx --progress ${items} '${work}'/"
eval ${debug} "touch stamp-r-index"
fi
# run the build
case "${run}" in
[yY]|[yY][eE][sS])
eval ${debug} "time make 'stamp-r-index' DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
case "${IndexOnly}" in
[yY]|[yY][eE][sS])
;;
*)
case "${seq}" in
[yY]|[yY][eE][sS])
eval ${debug} "time make -j3 '${farm}-parse' DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
eval ${debug} "time make '${farm}-render' DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
;;
*)
eval ${debug} "time make -j3 '${farm}' DESTDIR='${dest}' WORKDIR='${work}' XML_FILES='${xml}'"
;;
esac
esac
esac