source: trunk/src/ircaam_profile.sh @ 85

Last change on this file since 85 was 85, checked in by pinsard, 14 years ago

better representation of variable parts in filenames

  • 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#
122LANG=C
123#
124# as this script might be launch in .profile, command is forced.
125command=ircaam_profile.sh
126#
127usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir"
128#
129set +u
130while [ ! -z "${1}" ]
131do
132   case ${1} in
133      -d)
134         # directory for application choosen by user (see svn checkout command used)
135         directory=${2}
136         shift
137      ;;
138      -i)
139         # directory for inputs choosen by user
140         indir=${2}
141         shift
142      ;;
143      -o)
144         # directory for outputs choosen by user
145         outdir=${2}
146         shift
147      ;;
148      -t)
149         # directory for temporary outputs choosen by user
150         tempdir=${2}
151         shift
152      ;;
153      *)
154         # other choice
155         echo "eee : unknown option ${1}"
156         echo "${usage}"
157         # nb : no exit because this file should be launched by login process
158      ;;
159   esac
160   # next flag
161   shift
162done
163unset usage
164#
165# check for ${directory}
166if [ ! -d ${directory} ]
167then
168   echo " eee : ${directory} not found"
169   # nb : no exit because this file should be launched by login process
170fi
171#
172# check for permission on directory
173if [ ! -x ${directory} ]
174then
175   echo " eee : ${directory} not reachable"
176   # nb : no exit because this file should be launched by login process
177fi
178#
179set -u
180#
181IRCAAM=${directory}
182export IRCAAM
183unset directory
184#
185# add IRCAAM tools to PATH
186# if not already done
187suppath=$(echo ${IRCAAM} | tr -s "/")
188echo ${PATH} | grep -q "${suppath}:"
189test_path=${?}
190if [ ${test_path} -ne 0 ]
191then
192   PATH=${suppath}:${PATH}
193   export PATH
194else
195   # option bavarde oui/non pas encore implantée ++
196   echo "${command} : iii : ${suppath} already in \${PATH}"
197fi
198unset test_path
199unset suppath
200#
201# add ${IRCAAM}/../bin tools to PATH
202# if not already done
203suppath=$(echo ${IRCAAM}/../bin | tr -s "/")
204echo ${PATH} | grep -q "${suppath}:"
205test_path=${?}
206if [ ${test_path} -ne 0 ]
207then
208   PATH=${suppath}:${PATH}
209   export PATH
210else
211   # option bavarde oui/non pas encore implantée ++
212   echo "${command} : iii : ${suppath} already in \${PATH}"
213fi
214unset test_path
215unset suppath
216#
217# add IRCAAM manuals to MANPATH
218# if not already done
219suppath=$(echo ${IRCAAM}/doc/manuals/man | tr -s "/")
220echo ${MANPATH} | grep -q ${suppath}
221test_manpath=${?}
222if [ ${test_manpath} -ne 0 ]
223then
224   MANPATH=${suppath}:${MANPATH}
225   export MANPATH
226else
227   # option bavarde oui/non pas encore implantée ++
228   echo "${command} : iii : ${suppath} already in \${MANPATH}"
229fi
230unset test_manpath
231unset suppath
232#
233IRCAAM_LOG=${tempdir}
234export IRCAAM_LOG
235unset tempdir
236if [ ! -d ${IRCAAM_LOG} ]
237then
238   mkdir -p ${IRCAAM_LOG}
239   status=${?}
240   if [ ${status} -ne 0 ]
241   then
242      echo "${command} : eee : can not create \${IRCAAM_LOG}"
243      # nb : no exit because this file should be launched by login process
244   else
245      echo "${command} : iii : creation of \${IRCAAM_LOG}"
246   fi
247   unset status
248fi
249# check for permission on IRCAAM_LOG
250if [ ! -x ${IRCAAM_LOG} ]
251then
252   echo " eee : ${IRCAAM_LOG} not reachable"
253   # nb : no exit because this file should be launched by login process
254fi
255#
256# check for permission on IRCAAM_LOG
257if [ ! -w ${IRCAAM_LOG} ]
258then
259   echo " eee : ${IRCAAM_LOG} not writable"
260   # nb : no exit because this file shouldreachable be launched by login process
261fi
262#
263EDITOR=vi
264export EDITOR
265#
266# io directories
267IRCAAM_ID=${indir}
268export IRCAAM_ID
269unset indir
270if [ ! -d ${IRCAAM_ID} ]
271then
272  mkdir -p ${IRCAAM_ID}
273  echo "${command} : iii : creation of \${IRCAAM_ID}"
274fi
275# check for permission on IRCAAM_ID
276if [ ! -x ${IRCAAM_ID} ]
277then
278   echo " eee : ${IRCAAM_ID} not reachable"
279   # nb : no exit because this file should be launched by login process
280fi
281#
282IRCAAM_OD=${outdir}
283export IRCAAM_OD
284unset outdir
285if [ ! -d ${IRCAAM_OD} ]
286then
287   mkdir -p ${IRCAAM_OD}
288   echo "${command} : iii : creation of \${IRCAAM_OD}"
289fi
290# check for permission on IRCAAM_OD
291if [ ! -x ${IRCAAM_OD} ]
292then
293 echo " eee : ${IRCAAM_OD} not reachable"
294 # nb : no exit because this file should be launched by login process
295fi
296if [ ! -w ${IRCAAM_OD} ]
297then
298 echo " eee : ${IRCAAM_OD} not writable"
299 # nb : no exit because this file should be launched by login process
300fi
301#
302# end
303unset command
304#
305# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.