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