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