1 | #! /bin/sh -xv |
---|
2 | # |
---|
3 | #+ |
---|
4 | # |
---|
5 | # NAME |
---|
6 | # ==== |
---|
7 | # |
---|
8 | # geomag_profile.sh - define GEOMAG environment |
---|
9 | # |
---|
10 | # SYNOPSIS |
---|
11 | # ======== |
---|
12 | # |
---|
13 | # Online usage |
---|
14 | # |
---|
15 | # :: |
---|
16 | # |
---|
17 | # $ . geomag_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
18 | # |
---|
19 | # In ${HOME}/.profile, add the following line |
---|
20 | # |
---|
21 | # :: |
---|
22 | # |
---|
23 | # . geomag_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
24 | # |
---|
25 | # DESCRIPTION |
---|
26 | # =========== |
---|
27 | # |
---|
28 | # define GEOMAG environment |
---|
29 | # |
---|
30 | # ${GEOMAG} is the base directory of tools. |
---|
31 | # |
---|
32 | # ${GEOMAG_LOG} is the directory where log files will be written. |
---|
33 | # |
---|
34 | # ${GEOMAG_ID} is the directory where input files must be. |
---|
35 | # |
---|
36 | # ${GEOMAG_OD} is the directory where output files will be written. |
---|
37 | # |
---|
38 | # MANPATH++ |
---|
39 | # |
---|
40 | # EXAMPLES |
---|
41 | # ======== |
---|
42 | # |
---|
43 | # For fplod, on aedon.locean-ipsl.upmc.fr: |
---|
44 | # :: |
---|
45 | # |
---|
46 | # $ cd /usr/home/fplod/incas/geomag/geomag_ws |
---|
47 | # $ . geomag_profile.sh -d /usr/home/fplod/incas/geomag/geomag_ws/ -i ${HOME}/geomag_d/ -o ${HOME}/geomag_d/ -t /usr/temp/${LOGNAME}/log/ |
---|
48 | # |
---|
49 | # For reee522 on rhodes.idris.fr: |
---|
50 | # :: |
---|
51 | # |
---|
52 | # $ cd ${HOME}/incas/geomag/geomag_ws/ |
---|
53 | # $ . geomag_profile.sh -d ${HOME}/incas/geomag/geomag_ws/ -i ${HOMEGAYA}/geomag_d/ -o ${HOMEGAYA}/geomag_d/ -t /tmp/${LOGNAME}/log/ |
---|
54 | # |
---|
55 | # |
---|
56 | # FILES |
---|
57 | # ===== |
---|
58 | # |
---|
59 | # original location |
---|
60 | # ~~~~~~~~~~~~~~~~~ |
---|
61 | # |
---|
62 | # /usr/home/fplod/incas/geomag/geomag_ws/geomag_profile.sh sur aedon.locean-ipsl.upmc.fr |
---|
63 | # |
---|
64 | # EVOLUTIONS |
---|
65 | # ========== |
---|
66 | # |
---|
67 | # ++ option bavarde |
---|
68 | # |
---|
69 | # ++ machine dependant |
---|
70 | # |
---|
71 | # ++ besoin de posix |
---|
72 | # |
---|
73 | # ++ pas de MANPATH defini par déubt sur zeus |
---|
74 | # |
---|
75 | # $Id$ |
---|
76 | # |
---|
77 | # - reee522 2007-06-14T14:25:00Z rhodes (IRIX64) |
---|
78 | # |
---|
79 | # * add -i, -o and -t parameters to be more flexible |
---|
80 | # * some bug fixes |
---|
81 | # * more checking |
---|
82 | # |
---|
83 | # - fplod 2007-03-13T16:12:41Z zeus.locean-ipsl.upmc.fr (Linux) |
---|
84 | # |
---|
85 | # * add creation of $GEOMAG_ID and $GEOMAG_OD if they don't exist |
---|
86 | # |
---|
87 | # - reee522 2006-11-23T11:41:41Z rhodes (IRIX64) |
---|
88 | # |
---|
89 | # * pas de set -o posix sur rhodes (IRIX64) |
---|
90 | # |
---|
91 | # - fplod 2006-03-22T10:13:38Z aedon.lodyc.jussieu.fr (Darwin) |
---|
92 | # |
---|
93 | # * creation |
---|
94 | # |
---|
95 | #- |
---|
96 | # |
---|
97 | command=geomag_profile.sh |
---|
98 | # |
---|
99 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" |
---|
100 | # |
---|
101 | while [ ! -z "${1}" ] # ++ pb bash |
---|
102 | do |
---|
103 | case ${1} in |
---|
104 | -d) # directory for application choosen by user (see svn checkout command used) |
---|
105 | directory=${2} |
---|
106 | shift |
---|
107 | ;; |
---|
108 | -i) # directory for inputs choosen by user |
---|
109 | indir=${2} |
---|
110 | shift |
---|
111 | ;; |
---|
112 | -o) # directory for outputs choosen by user |
---|
113 | outdir=${2} |
---|
114 | shift |
---|
115 | ;; |
---|
116 | -t) # directory for temporary outputs choosen by user |
---|
117 | tempdir=${2} |
---|
118 | shift |
---|
119 | ;; |
---|
120 | |
---|
121 | *) # other choice |
---|
122 | echo "${usage}" |
---|
123 | # nb : no exit because this file should be launched by login process |
---|
124 | ;; |
---|
125 | esac |
---|
126 | shift # next flag |
---|
127 | done |
---|
128 | |
---|
129 | # check for ${directory} |
---|
130 | if [ ! -d ${directory} ] |
---|
131 | then |
---|
132 | echo " eee : ${directory} not found" |
---|
133 | # nb : no exit because this file should be launched by login process |
---|
134 | fi |
---|
135 | # |
---|
136 | # check for permission on directory |
---|
137 | if [ ! -x ${directory} ] |
---|
138 | then |
---|
139 | echo " eee : ${directory} not reachable" |
---|
140 | # nb : no exit because this file should be launched by login process |
---|
141 | fi |
---|
142 | # |
---|
143 | set -u |
---|
144 | system=$(uname) |
---|
145 | case "${system}" in |
---|
146 | IRIX64) |
---|
147 | echo " www : no specific posix checking" |
---|
148 | ;; |
---|
149 | *) |
---|
150 | set -o posix |
---|
151 | ;; |
---|
152 | esac |
---|
153 | # |
---|
154 | GEOMAG=${directory} |
---|
155 | export GEOMAG |
---|
156 | # |
---|
157 | # add GEOMAG tools to PATH |
---|
158 | # if not already done |
---|
159 | echo ${PATH} | grep -q ${GEOMAG} |
---|
160 | test_path=${?} |
---|
161 | if [ ${test_path} -ne 0 ] |
---|
162 | then |
---|
163 | PATH=${GEOMAG}/:${PATH} |
---|
164 | export PATH |
---|
165 | else |
---|
166 | # option bavarde oui/non pas encore implantée ++ |
---|
167 | echo "${command} : iii : ${GEOMAG}/ already in \${PATH}" |
---|
168 | fi |
---|
169 | # |
---|
170 | # add GEOMAG manuals to MANPATH |
---|
171 | # if not already done |
---|
172 | echo ${MANPATH} | grep -q ${GEOMAG} |
---|
173 | test_manpath=${?} |
---|
174 | if [ ${test_manpath} -ne 0 ] |
---|
175 | then |
---|
176 | MANPATH=${GEOMAG}/man/:${MANPATH} |
---|
177 | export MANPATH |
---|
178 | else |
---|
179 | # option bavarde oui/non pas encore implantée ++ |
---|
180 | echo "${command} : iii : ${GEOMAG}/man/ already in \${MANPATH}" |
---|
181 | fi |
---|
182 | # |
---|
183 | GEOMAG_LOG=${tempdir} |
---|
184 | export GEOMAG_LOG |
---|
185 | if [ ! -d ${GEOMAG_LOG} ] |
---|
186 | then |
---|
187 | mkdir -p ${GEOMAG_LOG} |
---|
188 | echo "${command} : iii : creation of \${GEOMAG_LOG}" |
---|
189 | fi |
---|
190 | # check for permission on GEOMAG_LOG |
---|
191 | if [ ! -x ${GEOMAG_LOG} ] |
---|
192 | then |
---|
193 | echo " eee : ${GEOMAG_LOG} not reachable" |
---|
194 | # nb : no exit because this file should be launched by login process |
---|
195 | fi |
---|
196 | # |
---|
197 | # check for permission on GEOMAG_LOG |
---|
198 | if [ ! -w ${GEOMAG_LOG} ] |
---|
199 | then |
---|
200 | echo " eee : ${GEOMAG_LOG} not writable" |
---|
201 | # nb : no exit because this file shouldreachable be launched by login process |
---|
202 | fi |
---|
203 | # |
---|
204 | EDITOR=vi |
---|
205 | export EDITOR |
---|
206 | # |
---|
207 | # io directories |
---|
208 | GEOMAG_ID=${indir} |
---|
209 | export GEOMAG_ID |
---|
210 | if [ ! -d ${GEOMAG_ID} ] |
---|
211 | then |
---|
212 | mkdir -p ${GEOMAG_ID} |
---|
213 | echo "${command} : iii : creation of \${GEOMAG_ID}" |
---|
214 | fi |
---|
215 | # check for permission on GEOMAG_ID |
---|
216 | if [ ! -x ${GEOMAG_ID} ] |
---|
217 | then |
---|
218 | echo " eee : ${GEOMAG_ID} not reachable" |
---|
219 | # nb : no exit because this file should be launched by login process |
---|
220 | fi |
---|
221 | # |
---|
222 | GEOMAG_OD=${outdir} |
---|
223 | export GEOMAG_OD |
---|
224 | if [ ! -d ${GEOMAG_OD} ] |
---|
225 | then |
---|
226 | mkdir -p ${GEOMAG_OD} |
---|
227 | echo "${command} : iii : creation of \${GEOMAG_OD}" |
---|
228 | fi |
---|
229 | # check for permission on GEOMAG_OD |
---|
230 | if [ ! -x ${GEOMAG_OD} ] |
---|
231 | then |
---|
232 | echo " eee : ${GEOMAG_OD} not reachable" |
---|
233 | # nb : no exit because this file should be launched by login process |
---|
234 | fi |
---|
235 | if [ ! -w ${GEOMAG_OD} ] |
---|
236 | then |
---|
237 | echo " eee : ${GEOMAG_OD} not writable" |
---|
238 | # nb : no exit because this file should be launched by login process |
---|
239 | fi |
---|
240 | # |
---|
241 | # end |
---|
242 | # nb : no exit because this file should be launched by login process |
---|