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