1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. program:: project_profile.sh |
---|
5 | # |
---|
6 | # =================== |
---|
7 | # project_profile.sh |
---|
8 | # =================== |
---|
9 | # |
---|
10 | # |
---|
11 | # SYNOPSIS |
---|
12 | # ======== |
---|
13 | # |
---|
14 | # On line usage: |
---|
15 | # |
---|
16 | # .. code-block:: sh |
---|
17 | # |
---|
18 | # ./project_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
19 | # |
---|
20 | # In :file:`${HOME}/.profile`, add the following line: |
---|
21 | # |
---|
22 | # .. code-block:: sh |
---|
23 | # |
---|
24 | # . project_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
25 | # |
---|
26 | # DESCRIPTION |
---|
27 | # =========== |
---|
28 | # |
---|
29 | # .. option:: -d <directory> |
---|
30 | # .. option:: -i <indir> |
---|
31 | # .. option:: -o <outdir> |
---|
32 | # .. option:: -t <tempdir> |
---|
33 | # .. option:: -jv <jabref version> |
---|
34 | # .. option:: -j <jabref dir> |
---|
35 | # |
---|
36 | # define SUPERBIB environment |
---|
37 | # |
---|
38 | # ${PROJECT} is the base directory of tools. |
---|
39 | # |
---|
40 | # ${PROJECT_LOG} is the directory where log files will be written. |
---|
41 | # |
---|
42 | # ${PROJECT_ID} is the directory where input files must be. |
---|
43 | # |
---|
44 | # ${PROJECT_OD} is the directory where output files will be written. |
---|
45 | # |
---|
46 | # MANPATH++ |
---|
47 | # |
---|
48 | # :envvar:`${xmlcmd}` is set to either xml or xmlstarlet if one of these |
---|
49 | # is available. |
---|
50 | # |
---|
51 | # EXAMPLES |
---|
52 | # ======== |
---|
53 | # |
---|
54 | # For fplod, on cratos.locean-ipsl.upmc.fr: |
---|
55 | # |
---|
56 | # .. code-block:: bash |
---|
57 | # |
---|
58 | # cd /usr/home/fplod/src/superbib/superbib_ws/ |
---|
59 | # SUPERBIB=${HOME}/superbib_ws/ |
---|
60 | # export SUPERBIB |
---|
61 | # . ${SUPERBIB}/project_profile.sh \ |
---|
62 | # -d ${SUPERBIB} \ |
---|
63 | # -i /usr/temp/${LOGNAME}/superbib_d/ \ |
---|
64 | # -o /usr/temp/${LOGNAME}/superbib_d/ \ |
---|
65 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
66 | # -jv 2.6 \ |
---|
67 | # -j /usr/home/incas/francoise/jabref-2.6_cratos/ |
---|
68 | # -b ++ |
---|
69 | # |
---|
70 | # TODO |
---|
71 | # ==== |
---|
72 | # |
---|
73 | # ++ option bavarde |
---|
74 | # |
---|
75 | # ++ machine dependant |
---|
76 | # |
---|
77 | # ++ pas de MANPATH défini par défaut sur zeus |
---|
78 | # |
---|
79 | # réintégration de bibliolocean dans trunk ou projet bibliolocean à part |
---|
80 | # |
---|
81 | # doc sur jabref dir bibtool |
---|
82 | # |
---|
83 | # EVOLUTIONS |
---|
84 | # ========== |
---|
85 | # |
---|
86 | # $Id$ |
---|
87 | # |
---|
88 | # $URL$ |
---|
89 | # |
---|
90 | # - fplod 20131010T113730Z callisto.locean-ipsl.upmc.fr (Linux) |
---|
91 | # |
---|
92 | # * dynamic xmlstarlet vs xml |
---|
93 | # |
---|
94 | # - fplod 20130418T110932Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
95 | # |
---|
96 | # * add PYTHONPATH (seems to be need be sphinx-apidoc + sphinx-build) |
---|
97 | # |
---|
98 | # - fplod 20120629T120311Z cratos (Linux) |
---|
99 | # |
---|
100 | # * path with branches/bibliolocean/src |
---|
101 | # |
---|
102 | # - fplod 20120405T085555Z cratos (Linux) |
---|
103 | # |
---|
104 | # * rename and replace SUPERBIB by PROJECT |
---|
105 | # |
---|
106 | # - fplod 20100426T094821Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
107 | # |
---|
108 | # * improve PATH and MANPATH modification |
---|
109 | # |
---|
110 | # - fplod 20100423T144248Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
111 | # |
---|
112 | # * add error handling on mkdir |
---|
113 | # |
---|
114 | # - fplod 2008-10-31T11:17:24Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
115 | # |
---|
116 | # * creation ++ pas encore en service |
---|
117 | # |
---|
118 | #- |
---|
119 | system=$(uname) |
---|
120 | case "${system}" in |
---|
121 | AIX|IRIX64) |
---|
122 | echo " www : no specific posix checking" |
---|
123 | ;; |
---|
124 | *) |
---|
125 | set -o posix |
---|
126 | ;; |
---|
127 | esac |
---|
128 | unset system |
---|
129 | # |
---|
130 | set -u |
---|
131 | # |
---|
132 | # as this script might be launch in .profile, command is forced. |
---|
133 | command=project_profile.sh |
---|
134 | # |
---|
135 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -jv jabrefversion -j jabrefdir -b bibtooldir" |
---|
136 | # |
---|
137 | while [ ${#} -gt 0 ] |
---|
138 | do |
---|
139 | case ${1} in |
---|
140 | -d) |
---|
141 | # directory for application chosen by user |
---|
142 | # (see svn checkout command used) |
---|
143 | directory=${2} |
---|
144 | shift |
---|
145 | ;; |
---|
146 | -i) |
---|
147 | # directory for inputs chosen by user |
---|
148 | indir=${2} |
---|
149 | shift |
---|
150 | ;; |
---|
151 | -o) |
---|
152 | # directory for outputs chosen by user |
---|
153 | outdir=${2} |
---|
154 | shift |
---|
155 | ;; |
---|
156 | -t) |
---|
157 | # directory for temporary outputs chosen by user |
---|
158 | tempdir=${2} |
---|
159 | shift |
---|
160 | ;; |
---|
161 | -jv) |
---|
162 | jabrefversion=${2} |
---|
163 | shift |
---|
164 | ;; |
---|
165 | -j) |
---|
166 | jabrefdir=${2} |
---|
167 | shift |
---|
168 | ;; |
---|
169 | -b) |
---|
170 | bibtooldir=${2} |
---|
171 | shift |
---|
172 | ;; |
---|
173 | *) |
---|
174 | # other choice |
---|
175 | echo "eee : unknown option ${1}" |
---|
176 | echo "${usage}" |
---|
177 | # nb : no exit because this file should be launched by |
---|
178 | # login process |
---|
179 | ;; |
---|
180 | esac |
---|
181 | # next flag |
---|
182 | shift |
---|
183 | done |
---|
184 | unset usage |
---|
185 | # |
---|
186 | # check for ${directory} |
---|
187 | if [ ! -d ${directory} ] |
---|
188 | then |
---|
189 | echo " eee : ${directory} not found" |
---|
190 | # nb : no exit because this file should be launched by login process |
---|
191 | fi |
---|
192 | # |
---|
193 | # check for permission on directory |
---|
194 | if [ ! -x ${directory} ] |
---|
195 | then |
---|
196 | echo " eee : ${directory} not reachable" |
---|
197 | # nb : no exit because this file should be launched by login process |
---|
198 | fi |
---|
199 | # |
---|
200 | PROJECT=${directory} |
---|
201 | export PROJECT |
---|
202 | # |
---|
203 | # add PROJECT tools to PATH |
---|
204 | # if not already done |
---|
205 | suppath=$(echo ${PROJECT} | tr -s "/") |
---|
206 | echo ${PATH} | grep -q "${suppath}:" |
---|
207 | test_path=${?} |
---|
208 | if [ ${test_path} -ne 0 ] |
---|
209 | then |
---|
210 | PATH=${suppath}:${PATH} |
---|
211 | export PATH |
---|
212 | else |
---|
213 | # option bavarde oui/non pas encore implantée ++ |
---|
214 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
215 | fi |
---|
216 | unset test_path |
---|
217 | unset suppath |
---|
218 | # |
---|
219 | suppath=$(echo ${PROJECT}/../branches/bibliolocean/src | tr -s "/") |
---|
220 | echo ${PATH} | grep -q "${suppath}:" |
---|
221 | test_path=${?} |
---|
222 | if [ ${test_path} -ne 0 ] |
---|
223 | then |
---|
224 | PATH=${suppath}:${PATH} |
---|
225 | export PATH |
---|
226 | else |
---|
227 | # option bavarde oui/non pas encore implantée ++ |
---|
228 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
229 | fi |
---|
230 | unset test_path |
---|
231 | # |
---|
232 | # add PROJECT tools to PYTHONPATH |
---|
233 | # if not already done |
---|
234 | suppath=$(echo ${PROJECT}/aeres/scripts/ | tr -s "/") |
---|
235 | echo ${PYTHONPATH} | grep -q "${suppath}:" |
---|
236 | test_path=${?} |
---|
237 | if [ ${test_path} -ne 0 ] |
---|
238 | then |
---|
239 | PYTHONPATH=${suppath}:${PYTHONPATH} |
---|
240 | export PYTHONPATH |
---|
241 | else |
---|
242 | # option bavarde oui/non pas encore implantée ++ |
---|
243 | echo "${command} : iii : ${suppath} already in \${PYTHONPATH}" |
---|
244 | fi |
---|
245 | unset test_path |
---|
246 | unset suppath |
---|
247 | # |
---|
248 | # add PROJECT tools to PYTHONPATH |
---|
249 | # if not already done |
---|
250 | suppath=$(echo ${PROJECT}/| tr -s "/") |
---|
251 | echo ${PYTHONPATH} | grep -q "${suppath}:" |
---|
252 | test_path=${?} |
---|
253 | if [ ${test_path} -ne 0 ] |
---|
254 | then |
---|
255 | PYTHONPATH=${suppath}:${PYTHONPATH} |
---|
256 | export PYTHONPATH |
---|
257 | else |
---|
258 | # option bavarde oui/non pas encore implantée ++ |
---|
259 | echo "${command} : iii : ${suppath} already in \${PYTHONPATH}" |
---|
260 | fi |
---|
261 | unset test_path |
---|
262 | unset suppath |
---|
263 | # |
---|
264 | # add PROJECT manuals to MANPATH |
---|
265 | # if not already done |
---|
266 | suppath=$(echo ${PROJECT}/doc/manuals/man | tr -s "/") |
---|
267 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
268 | test_manpath=${?} |
---|
269 | if [ ${test_manpath} -ne 0 ] |
---|
270 | then |
---|
271 | MANPATH=${suppath}:${MANPATH} |
---|
272 | export MANPATH |
---|
273 | else |
---|
274 | # option bavarde oui/non pas encore implantée ++ |
---|
275 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
276 | fi |
---|
277 | unset test_manpath |
---|
278 | unset suppath |
---|
279 | # |
---|
280 | PROJECT_LOG=${tempdir} |
---|
281 | export PROJECT_LOG |
---|
282 | unset tempdir |
---|
283 | if [ ! -d ${PROJECT_LOG} ] |
---|
284 | then |
---|
285 | mkdir -p ${PROJECT_LOG} |
---|
286 | status=${?} |
---|
287 | if [ ${status} -ne 0 ] |
---|
288 | then |
---|
289 | echo "${command} : eee : can not create \${PROJECT_LOG}" |
---|
290 | # nb : no exit because this file should be launched by login process |
---|
291 | else |
---|
292 | echo "${command} : iii : creation of \${PROJECT_LOG}" |
---|
293 | fi |
---|
294 | unset status |
---|
295 | fi |
---|
296 | # check for permission on PROJECT_LOG |
---|
297 | if [ ! -x ${PROJECT_LOG} ] |
---|
298 | then |
---|
299 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
300 | # nb : no exit because this file should be launched by login process |
---|
301 | fi |
---|
302 | # |
---|
303 | # check for permission on PROJECT_LOG |
---|
304 | if [ ! -w ${PROJECT_LOG} ] |
---|
305 | then |
---|
306 | echo " eee : ${PROJECT_LOG} not writable" |
---|
307 | # nb : no exit because this file shouldreachable be launched |
---|
308 | # by login process |
---|
309 | fi |
---|
310 | # |
---|
311 | EDITOR=vi |
---|
312 | export EDITOR |
---|
313 | # |
---|
314 | # io directories |
---|
315 | PROJECT_ID=${indir} |
---|
316 | export PROJECT_ID |
---|
317 | unset indir |
---|
318 | if [ ! -d ${PROJECT_ID} ] |
---|
319 | then |
---|
320 | mkdir -p ${PROJECT_ID} |
---|
321 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
322 | fi |
---|
323 | # check for permission on PROJECT_ID |
---|
324 | if [ ! -x ${PROJECT_ID} ] |
---|
325 | then |
---|
326 | echo " eee : ${PROJECT_ID} not reachable" |
---|
327 | # nb : no exit because this file should be launched by login process |
---|
328 | fi |
---|
329 | # |
---|
330 | PROJECT_OD=${outdir} |
---|
331 | export PROJECT_OD |
---|
332 | unset outdir |
---|
333 | if [ ! -d ${PROJECT_OD} ] |
---|
334 | then |
---|
335 | mkdir -p ${PROJECT_OD} |
---|
336 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
337 | fi |
---|
338 | # check for permission on PROJECT_OD |
---|
339 | if [ ! -x ${PROJECT_OD} ] |
---|
340 | then |
---|
341 | echo " eee : ${PROJECT_OD} not reachable" |
---|
342 | # nb : no exit because this file should be launched by login process |
---|
343 | fi |
---|
344 | if [ ! -w ${PROJECT_OD} ] |
---|
345 | then |
---|
346 | echo " eee : ${PROJECT_OD} not writable" |
---|
347 | # nb : no exit because this file should be launched by login process |
---|
348 | fi |
---|
349 | # |
---|
350 | JABREF_DIR=${jabrefdir} |
---|
351 | export JABREF_DIR |
---|
352 | unset jabref_dir |
---|
353 | JABREF_VERSION=${jabrefversion} |
---|
354 | export JABREF_VERSION |
---|
355 | unset jabrefversion |
---|
356 | # |
---|
357 | BIBTOOL_DIR=${bibtooldir} |
---|
358 | export BIBTOOL_DIR |
---|
359 | unset bibtooldir |
---|
360 | PATH=${BIBTOOL_DIR}:${PATH} |
---|
361 | export PATH |
---|
362 | # |
---|
363 | # test if which xml is available xml or xmlstarlet |
---|
364 | tool=xml |
---|
365 | type ${tool} 1> /dev/null 2>&1 |
---|
366 | status=${?} |
---|
367 | if [ ${status} -ne 0 ] |
---|
368 | then |
---|
369 | #echo "${command} : www : tool ${tool} not found" |
---|
370 | tool=xmlstarlet |
---|
371 | type ${tool} 1> /dev/null 2>&1 |
---|
372 | status=${?} |
---|
373 | if [ ${status} -ne 0 ] |
---|
374 | then |
---|
375 | echo "${command} : eee : tool ${tool} not found" |
---|
376 | else |
---|
377 | xmlcmd=xmlstarlet |
---|
378 | fi |
---|
379 | else |
---|
380 | xmlcmd=xml |
---|
381 | fi |
---|
382 | export xmlcmd |
---|
383 | # |
---|
384 | unset status |
---|
385 | unset tool |
---|
386 | |
---|
387 | # end |
---|
388 | unset command |
---|
389 | # nb : no exit because this file should be launched by login process |
---|