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