1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. program:: project_profile.sh |
---|
5 | # |
---|
6 | # .. _project_profile.sh: |
---|
7 | # |
---|
8 | # ================================================== |
---|
9 | # project_profile.sh -- define PROJECT environment |
---|
10 | # ================================================== |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # Online usage:: |
---|
16 | # |
---|
17 | # $ . ./project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir |
---|
18 | # |
---|
19 | # In ${HOME}/.profile, add the following line:: |
---|
20 | # |
---|
21 | # . project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir |
---|
22 | # |
---|
23 | # DESCRIPTION |
---|
24 | # =========== |
---|
25 | # |
---|
26 | # .. option:: -d <directory> |
---|
27 | # .. option:: -i <indir> |
---|
28 | # .. option:: -o <outdir> |
---|
29 | # .. option:: -t <tempdir> |
---|
30 | # .. option:: -s <saxo_dir> |
---|
31 | # |
---|
32 | # define PROJECT environment |
---|
33 | # |
---|
34 | # ${PROJECT} is the base directory of tools. |
---|
35 | # |
---|
36 | # ${PROJECT_LOG} is the directory where log files will be written. |
---|
37 | # |
---|
38 | # ${PROJECT_ID} is the directory where input files must be. |
---|
39 | # |
---|
40 | # ${PROJECT_OD} is the directory where output files will be written. |
---|
41 | # |
---|
42 | # PATH is completed with ${PROJECT}/src/. |
---|
43 | # |
---|
44 | # ${SAXO_DIR} is the base directory of SAXO tools |
---|
45 | # |
---|
46 | # IDL_STARTUP is set to tell IDL where find tools. |
---|
47 | # |
---|
48 | # FER_GO is completed with ${PROJECT}/src/. |
---|
49 | # |
---|
50 | # |
---|
51 | # SEE ALSO |
---|
52 | # ======== |
---|
53 | # |
---|
54 | # for IDL/gdl and SAXO environment : |
---|
55 | # |
---|
56 | # :ref:`project_init.pro` |
---|
57 | # :ref:`cm_project.pro` |
---|
58 | # |
---|
59 | # EXAMPLES |
---|
60 | # ======== |
---|
61 | # |
---|
62 | # For fplod, on aedon.locean-ipsl.upmc.fr:: |
---|
63 | # |
---|
64 | # $ cd /usr/home/fplod/incas/tropflux/tropflux_ws/ |
---|
65 | # $ . ./src/project_profile.sh \ |
---|
66 | # -d $(pwd) \ |
---|
67 | # -i /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
68 | # -o /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
69 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
70 | # -s /usr/home/fplod/SAXO_DIR/ |
---|
71 | # |
---|
72 | # For fplod on cratos.locean-ipsl.umpc.fr:: |
---|
73 | # |
---|
74 | # $ cd ${HOME}/incas/tropflux/tropflux_ws/ |
---|
75 | # $ . ./src/project_profile.sh \ |
---|
76 | # -d $(pwd) \ |
---|
77 | # -i /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
78 | # -o /usr/temp/${LOGNAME}/tropflux_d/ \ |
---|
79 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
80 | # -s ${HOME}/SAXO_DIR/ |
---|
81 | # |
---|
82 | # For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv:: |
---|
83 | # |
---|
84 | # $ cd ${HOME}/tropflux/ |
---|
85 | # $ . ./src/project_profile.sh \ |
---|
86 | # -d $(pwd) \ |
---|
87 | # -i /homedata/${LOGNAME}/tropflux_d/ \ |
---|
88 | # -o /homedata/${LOGNAME}/tropflux_d/ \ |
---|
89 | # -t /homedata/${LOGNAME}/log/ |
---|
90 | # -s ${HOME}/SAXO_DIR/ |
---|
91 | # |
---|
92 | # TODO |
---|
93 | # ==== |
---|
94 | # |
---|
95 | # ++ option bavarde |
---|
96 | # |
---|
97 | # ++ machine dependant |
---|
98 | # |
---|
99 | # ++ besoin de posix |
---|
100 | # |
---|
101 | # ++ pas de MANPATH defini par défaut sur zeus et cerbere |
---|
102 | # |
---|
103 | # EVOLUTIONS |
---|
104 | # ========== |
---|
105 | # |
---|
106 | # $Id$ |
---|
107 | # |
---|
108 | # - fplod 20110502T155437Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
109 | # |
---|
110 | # * complete FER_GO |
---|
111 | # |
---|
112 | # - fplod 20110429T090524Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
113 | # |
---|
114 | # * set IDL_STARTUP |
---|
115 | # |
---|
116 | # - fplod 20110413T151541Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
117 | # |
---|
118 | # * fix uncompleted replacement SAXO_SRC by SAXO_DIR |
---|
119 | # |
---|
120 | # - fplod 20101118T171653Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
121 | # |
---|
122 | # * creation |
---|
123 | # |
---|
124 | #- |
---|
125 | system=$(uname) |
---|
126 | case "${system}" in |
---|
127 | AIX|IRIX64) |
---|
128 | echo " www : no specific posix checking" |
---|
129 | ;; |
---|
130 | *) |
---|
131 | set -o posix |
---|
132 | ;; |
---|
133 | esac |
---|
134 | unset system |
---|
135 | # |
---|
136 | LANG=C |
---|
137 | # |
---|
138 | # as this script might be launch in .profile, command is forced. |
---|
139 | command=project_profile.sh |
---|
140 | # |
---|
141 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir" |
---|
142 | # |
---|
143 | set +u |
---|
144 | while [ ! -z "${1}" ] |
---|
145 | do |
---|
146 | case ${1} in |
---|
147 | -d) |
---|
148 | # directory for application choosen by user (see svn checkout command used) |
---|
149 | directory=${2} |
---|
150 | shift |
---|
151 | ;; |
---|
152 | -i) |
---|
153 | # directory for inputs choosen by user |
---|
154 | indir=${2} |
---|
155 | shift |
---|
156 | ;; |
---|
157 | -o) |
---|
158 | # directory for outputs choosen by user |
---|
159 | outdir=${2} |
---|
160 | shift |
---|
161 | ;; |
---|
162 | -t) |
---|
163 | # directory for temporary outputs choosen by user |
---|
164 | tempdir=${2} |
---|
165 | shift |
---|
166 | ;; |
---|
167 | -s) |
---|
168 | # directory for SAXO tools |
---|
169 | saxo_dir=${2} |
---|
170 | shift |
---|
171 | ;; |
---|
172 | *) |
---|
173 | # other choice |
---|
174 | echo "eee : unknown option ${1}" |
---|
175 | echo "${usage}" |
---|
176 | # nb : no exit because this file should be launched by login process |
---|
177 | ;; |
---|
178 | esac |
---|
179 | # next flag |
---|
180 | shift |
---|
181 | done |
---|
182 | unset usage |
---|
183 | # |
---|
184 | # check for ${directory} |
---|
185 | if [ ! -d ${directory} ] |
---|
186 | then |
---|
187 | echo " eee : ${directory} not found" |
---|
188 | # nb : no exit because this file should be launched by login process |
---|
189 | fi |
---|
190 | # |
---|
191 | # check for permission on directory |
---|
192 | if [ ! -x ${directory} ] |
---|
193 | then |
---|
194 | echo " eee : ${directory} not reachable" |
---|
195 | # nb : no exit because this file should be launched by login process |
---|
196 | fi |
---|
197 | # |
---|
198 | PROJECT=${directory} |
---|
199 | export PROJECT |
---|
200 | unset drectory |
---|
201 | # |
---|
202 | # add PROJECT tools to PATH |
---|
203 | # if not already done |
---|
204 | suppath=$(echo ${PROJECT}/src | tr -s "/") |
---|
205 | echo ${PATH} | grep -q "${suppath}:" |
---|
206 | test_path=${?} |
---|
207 | if [ ${test_path} -ne 0 ] |
---|
208 | then |
---|
209 | PATH=${suppath}:${PATH} |
---|
210 | export PATH |
---|
211 | else |
---|
212 | # option bavarde oui/non pas encore implantée ++ |
---|
213 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
214 | fi |
---|
215 | unset test_path |
---|
216 | # |
---|
217 | # add PROJECT manuals to MANPATH |
---|
218 | # if not already done |
---|
219 | suppath=$(echo ${PROJECT}/doc/man | tr -s "/") |
---|
220 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
221 | test_manpath=${?} |
---|
222 | if [ ${test_manpath} -ne 0 ] |
---|
223 | then |
---|
224 | MANPATH=${suppath}:${MANPATH} |
---|
225 | export MANPATH |
---|
226 | else |
---|
227 | # option bavarde oui/non pas encore implantée ++ |
---|
228 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
229 | fi |
---|
230 | unset test_manpath |
---|
231 | unset suppath |
---|
232 | # |
---|
233 | PROJECT_LOG=${tempdir} |
---|
234 | export PROJECT_LOG |
---|
235 | unset tempdir |
---|
236 | if [ ! -d ${PROJECT_LOG} ] |
---|
237 | then |
---|
238 | mkdir -p ${PROJECT_LOG} |
---|
239 | status=${?} |
---|
240 | if [ ${status} -ne 0 ] |
---|
241 | then |
---|
242 | echo "${command} : eee : can not create \${PROJECT_LOG}" |
---|
243 | # nb : no exit because this file should be launched by login process |
---|
244 | else |
---|
245 | echo "${command} : iii : creation of \${PROJECT_LOG}" |
---|
246 | fi |
---|
247 | unset status |
---|
248 | fi |
---|
249 | # check for permission on PROJECT_LOG |
---|
250 | if [ ! -x ${PROJECT_LOG} ] |
---|
251 | then |
---|
252 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
253 | # nb : no exit because this file should be launched by login process |
---|
254 | fi |
---|
255 | # |
---|
256 | # check for permission on PROJECT_LOG |
---|
257 | if [ ! -w ${PROJECT_LOG} ] |
---|
258 | then |
---|
259 | echo " eee : ${PROJECT_LOG} not writable" |
---|
260 | # nb : no exit because this file shouldreachable be launched by login process |
---|
261 | fi |
---|
262 | # |
---|
263 | EDITOR=vi |
---|
264 | export EDITOR |
---|
265 | # |
---|
266 | # io directories |
---|
267 | PROJECT_ID=${indir} |
---|
268 | export PROJECT_ID |
---|
269 | unset indir |
---|
270 | if [ ! -d ${PROJECT_ID} ] |
---|
271 | then |
---|
272 | mkdir -p ${PROJECT_ID} |
---|
273 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
274 | fi |
---|
275 | # check for permission on PROJECT_ID |
---|
276 | if [ ! -x ${PROJECT_ID} ] |
---|
277 | then |
---|
278 | echo " eee : ${PROJECT_ID} not reachable" |
---|
279 | # nb : no exit because this file should be launched by login process |
---|
280 | fi |
---|
281 | # |
---|
282 | PROJECT_OD=${outdir} |
---|
283 | export PROJECT_OD |
---|
284 | unset outdir |
---|
285 | if [ ! -d ${PROJECT_OD} ] |
---|
286 | then |
---|
287 | mkdir -p ${PROJECT_OD} |
---|
288 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
289 | fi |
---|
290 | # check for permission on PROJECT_OD |
---|
291 | if [ ! -x ${PROJECT_OD} ] |
---|
292 | then |
---|
293 | echo " eee : ${PROJECT_OD} not reachable" |
---|
294 | # nb : no exit because this file should be launched by login process |
---|
295 | fi |
---|
296 | if [ ! -w ${PROJECT_OD} ] |
---|
297 | then |
---|
298 | echo " eee : ${PROJECT_OD} not writable" |
---|
299 | # nb : no exit because this file should be launched by login process |
---|
300 | fi |
---|
301 | # |
---|
302 | # setup for ferret |
---|
303 | FER_GO="${FER_GO} ${PROJECT}/src" |
---|
304 | export FER_GO |
---|
305 | # |
---|
306 | SAXO_DIR=${saxo_dir} |
---|
307 | export SAXO_DIR |
---|
308 | unset saxo_dir |
---|
309 | # |
---|
310 | # IDL startup |
---|
311 | IDL_STARTUP=${PROJECT}/src/project_init.pro |
---|
312 | export IDL_STARTUP |
---|
313 | # |
---|
314 | # end |
---|
315 | unset command |
---|
316 | # nb : no exit because this file should be launched by login process |
---|