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