source: trunk/src/ircaam_profile.sh @ 88

Last change on this file since 88 was 88, checked in by pinsard, 13 years ago

Consolidation of shell scripts

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