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