1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. program:: before.sh |
---|
5 | # |
---|
6 | # ========= |
---|
7 | # before.sh |
---|
8 | # ========= |
---|
9 | # |
---|
10 | # -------------------------------- |
---|
11 | # preparation of results directory |
---|
12 | # -------------------------------- |
---|
13 | # |
---|
14 | # SYNOPSIS |
---|
15 | # ======== |
---|
16 | # |
---|
17 | # .. code-block:: sh |
---|
18 | # |
---|
19 | # before.sh -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany |
---|
20 | # |
---|
21 | # DESCRIPTION |
---|
22 | # =========== |
---|
23 | # |
---|
24 | # preparation of temporary (before deployment) of superbib results directory |
---|
25 | # - tree; |
---|
26 | # - copy of constant images copie des images; |
---|
27 | # - copy of CSS style sheet; |
---|
28 | # - etc. |
---|
29 | # |
---|
30 | # .. option:: -s <source directory> |
---|
31 | # .. option:: -w <output directory> |
---|
32 | # .. option:: -l <language> |
---|
33 | # .. option:: -mono |
---|
34 | # |
---|
35 | # +todo+ |
---|
36 | # |
---|
37 | # .. option:: -multi |
---|
38 | # |
---|
39 | # +todo+ |
---|
40 | # |
---|
41 | # .. option:: -m |
---|
42 | # |
---|
43 | # +todo+ |
---|
44 | # |
---|
45 | # EXAMPLES |
---|
46 | # ======== |
---|
47 | # |
---|
48 | # TODO |
---|
49 | # ==== |
---|
50 | # |
---|
51 | # il faudrait autoriser plusieurs fois l'option :option:`-l` et utiliser un tableau de |
---|
52 | # langues pour créer autant de répertoires qu'il faut. |
---|
53 | # |
---|
54 | # EVOLUTIONS |
---|
55 | # ========== |
---|
56 | # |
---|
57 | # $Id$ |
---|
58 | # |
---|
59 | # - fplod 2008-09-16T15:19:59Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
60 | # |
---|
61 | # * comments in reStructuredText |
---|
62 | # |
---|
63 | # - fplod 2008-06-16T09:48:22Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
64 | # |
---|
65 | # * add copy of documents |
---|
66 | # |
---|
67 | # - fplod 2007-10-17T12:22:57Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
68 | # |
---|
69 | # * parametrisation of number of "many" presentation |
---|
70 | # |
---|
71 | # - fplod 2007-09-28T08:43:10Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
72 | # |
---|
73 | # * parametrisation and translation |
---|
74 | # |
---|
75 | # - fplod 2007-03-30T09:55:49Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
76 | # |
---|
77 | # * création |
---|
78 | # |
---|
79 | #- |
---|
80 | # |
---|
81 | system=$(uname) |
---|
82 | case "${system}" in |
---|
83 | AIX|IRIX64) |
---|
84 | echo " www : no specific posix checking" |
---|
85 | ;; |
---|
86 | *) |
---|
87 | set -o posix |
---|
88 | ;; |
---|
89 | esac |
---|
90 | unset system |
---|
91 | # |
---|
92 | set -u |
---|
93 | # |
---|
94 | command=$(basename ${0}) |
---|
95 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
96 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
97 | # |
---|
98 | usage=" Usage : ${command} -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany" |
---|
99 | # |
---|
100 | minargcount=9 |
---|
101 | #echo " narg ${#}" |
---|
102 | if [ ${#} -lt ${minargcount} ] |
---|
103 | then |
---|
104 | echo "eee : not enough arguments (${#} vs ${minargcount})" |
---|
105 | echo "${usage}" |
---|
106 | exit 1 |
---|
107 | fi |
---|
108 | unset minargcount |
---|
109 | # |
---|
110 | # default |
---|
111 | nmany=0 |
---|
112 | # |
---|
113 | while [ ${#} -gt 0 ] |
---|
114 | do |
---|
115 | case ${1} in |
---|
116 | -p) |
---|
117 | product=${2} |
---|
118 | shift |
---|
119 | ;; |
---|
120 | -s) |
---|
121 | dirsrc=${2} |
---|
122 | shift |
---|
123 | ;; |
---|
124 | -w) |
---|
125 | dirwww=${2} |
---|
126 | shift |
---|
127 | ;; |
---|
128 | -l) |
---|
129 | lang=${2} |
---|
130 | shift |
---|
131 | ;; |
---|
132 | -mono) |
---|
133 | monolingual=1 |
---|
134 | ;; |
---|
135 | -multi) |
---|
136 | monolingual=0 |
---|
137 | ;; |
---|
138 | -m) |
---|
139 | nmany=${2} |
---|
140 | shift |
---|
141 | ;; |
---|
142 | esac |
---|
143 | # next flag |
---|
144 | shift |
---|
145 | done |
---|
146 | unset usage |
---|
147 | # |
---|
148 | # destruction of previous installation |
---|
149 | /bin/rm -r ${dirwww}/ 2> /dev/null |
---|
150 | # |
---|
151 | # building of directories |
---|
152 | if [ -d ${dirsrc}/images/ ] |
---|
153 | then |
---|
154 | mkdir -p ${dirwww}/images/ |
---|
155 | if [ ${nmany} -gt 0 ] |
---|
156 | then |
---|
157 | mkdir -p ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'habitude dans les chunks |
---|
158 | fi |
---|
159 | fi |
---|
160 | # |
---|
161 | if [ -d ${dirsrc}/documents/ ] |
---|
162 | then |
---|
163 | mkdir -p ${dirwww}/documents/ |
---|
164 | fi |
---|
165 | # |
---|
166 | list_php="${dirsrc}/phpversion.php ${dirsrc}/server.php ${dirsrc}/timestamp.php" |
---|
167 | ls ${list_php} 1> /dev/null 2> /dev/null |
---|
168 | exist_php=${?} |
---|
169 | if [ ${exist_php} -eq 0 ] |
---|
170 | then |
---|
171 | mkdir -p ${dirwww}/php/ |
---|
172 | fi |
---|
173 | # |
---|
174 | if [ ${monolingual} -eq 0 ] |
---|
175 | then |
---|
176 | mkdir -p ${dirwww}/${lang}/one/ |
---|
177 | if [ ${nmany} -gt 0 ] |
---|
178 | then |
---|
179 | mkdir -p ${dirwww}/${lang}/many/ |
---|
180 | imany=1 |
---|
181 | while [ ${imany} -le ${nmany} ] |
---|
182 | do |
---|
183 | mkdir -p ${dirwww}/${lang}/many/${product}$(printf "%2.2d" ${imany})/ |
---|
184 | imany=$(( ${imany} + 1 )) |
---|
185 | done |
---|
186 | fi |
---|
187 | else |
---|
188 | mkdir -p ${dirwww}/one/ |
---|
189 | if [ ${nmany} -gt 0 ] |
---|
190 | then |
---|
191 | mkdir -p ${dirwww}/many/ |
---|
192 | imany=1 |
---|
193 | while [ ${imany} -le ${nmany} ] |
---|
194 | do |
---|
195 | mkdir -p ${dirwww}/many/${product}$(printf "%2.2d" ${imany})/ |
---|
196 | done |
---|
197 | fi |
---|
198 | fi |
---|
199 | # |
---|
200 | if [ ${exist_php} -eq 0 ] |
---|
201 | then |
---|
202 | for file_php in ${list_php} |
---|
203 | do |
---|
204 | cp ${file_php} ${dirwww}/php/ |
---|
205 | done |
---|
206 | fi |
---|
207 | unset exist_php |
---|
208 | # |
---|
209 | if [ -d ${dirsrc}/images/ ] |
---|
210 | then |
---|
211 | cp ${dirsrc}/images/* ${dirwww}/images/ |
---|
212 | if [ ${nmany} -gt 0 ] |
---|
213 | then |
---|
214 | cp ${dirsrc}/images/* ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'habitude dans les chunks |
---|
215 | fi |
---|
216 | fi |
---|
217 | # |
---|
218 | # copy of documents |
---|
219 | if [ -d ${dirsrc}/documents/ ] |
---|
220 | then |
---|
221 | cp ${dirsrc}/documents/* ${dirwww}/documents/ |
---|
222 | fi |
---|
223 | # |
---|
224 | # copy of CSS |
---|
225 | ls ${dirsrc}/*.css 1> /dev/null 2> /dev/null |
---|
226 | exist_css=${?} |
---|
227 | if [ ${exist_css} -eq 0 ] |
---|
228 | then |
---|
229 | cp ${dirsrc}/*.css ${dirwww}/ |
---|
230 | fi |
---|
231 | unset exist_css |
---|
232 | if [ ${nmany} -gt 0 ] |
---|
233 | then |
---|
234 | cp ${dirsrc}/*.css ${dirwww}/${lang}/ # ++ parce que un niveau de plus que d'habitude dans les chunks |
---|
235 | fi |
---|
236 | # |
---|
237 | # modification of directory time in order to trigger the generation of HTML |
---|
238 | # files |
---|
239 | find ${dirwww}/ -type d -exec touch -t 199912310000 {} \; |
---|
240 | # |
---|
241 | # end |
---|
242 | exit 0 |
---|