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