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