source: trunk/geomag_profile.sh @ 42

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

improvements of headers and unset in shell scripts

  • Property svn:executable set to *
  • Property svn:keyword set to Id
File size: 5.2 KB
Line 
1#! /bin/sh -xv
2#
3#+
4# =================
5# geomag_profile.sh
6# =================
7#
8# -------------------------
9# define GEOMAG environment
10# -------------------------
11#
12# SYNOPSIS
13# ========
14#
15# Online usage::
16#
17#  $ . geomag_profile.sh -d directory -i indir -o outdir -t tempdir
18#
19# In ${HOME}/.profile, add the following line::
20#
21#  . geomag_profile.sh -d directory  -i indir -o outdir -t tempdir
22#
23# DESCRIPTION
24# ===========
25#
26# define GEOMAG environment
27#
28# ${GEOMAG} is the base directory of tools.
29#
30# ${GEOMAG_LOG} is the directory where log files  will be written.
31#
32# ${GEOMAG_ID} is the directory where input files must be.
33#
34# ${GEOMAG_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/incas/geomag/geomag_ws
44#  $ . geomag_profile.sh -d /usr/home/fplod/incas/geomag/geomag_ws/ -i ${HOME}/geomag_d/ -o ${HOME}/geomag_d/ -t /usr/temp/${LOGNAME}/log/
45#
46# For reee522 on rhodes.idris.fr::
47#
48#  $ cd ${HOME}/incas/geomag/geomag_ws/
49#  $ . geomag_profile.sh -d ${HOME}/incas/geomag/geomag_ws/ -i ${HOMEGAYA}/geomag_d/ -o ${HOMEGAYA}/geomag_d/ -t /tmp/${LOGNAME}/log/
50#
51# TODO
52# ====
53#
54# ++ option bavarde
55#
56# ++ machine dependant
57#
58# ++ besoin de posix
59#
60# ++ pas de MANPATH defini par défaut sur zeus
61#
62# EVOLUTIONS
63# ==========
64#
65# $Id$
66#
67# - fplod 20100318T073619Z aedon.locean-ipsl.upmc.fr (Darwin)
68#
69#   * unset
70#
71# - reee522 2007-06-14T14:25:00Z rhodes (IRIX64)
72#
73#   * add -i, -o and -t parameters to be more flexible
74#   * some bug fixes
75#   * more checking
76#
77# - fplod 2007-03-13T16:12:41Z zeus.locean-ipsl.upmc.fr (Linux)
78#
79#   * add creation of $GEOMAG_ID and $GEOMAG_OD if they don't exist
80#
81# - reee522 2006-11-23T11:41:41Z rhodes (IRIX64)
82#
83#   * pas de set -o posix sur rhodes (IRIX64)
84#
85# - fplod 2006-03-22T10:13:38Z aedon.lodyc.jussieu.fr (Darwin)
86#
87#   * creation
88#
89#-
90#
91command=geomag_profile.sh
92#
93usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir"
94#
95set +u
96while [ ! -z "${1}" ] # ++ pb bash
97do
98 case ${1} in
99 -d) # directory for application choosen by user (see svn checkout command used)
100  directory=${2}
101  shift
102 ;;
103 -i) # directory for inputs choosen by user
104  indir=${2}
105  shift
106 ;;
107 -o) # directory for outputs choosen by user
108  outdir=${2}
109  shift
110 ;;
111 -t) # directory for temporary outputs choosen by user
112  tempdir=${2}
113  shift
114 ;;
115
116 *) # other choice
117  echo "eee : unknown option ${1}"
118  echo "${usage}"
119  # nb : no exit because this file should be launched by login process
120 ;;
121 esac
122 shift # next flag
123done
124unset usage
125#
126set -u
127#
128# check for ${directory}
129if [ ! -d ${directory} ]
130then
131 echo " eee : ${directory} not found"
132 # nb : no exit because this file should be launched by login process
133fi
134#
135# check for permission on directory
136if [ ! -x ${directory} ]
137then
138 echo " eee : ${directory} not reachable"
139 # nb : no exit because this file should be launched by login process
140fi
141#
142set -u
143system=$(uname)
144case "${system}" in
145IRIX64)
146  echo " www : no specific posix checking"
147;;
148*)
149  set -o posix
150;;
151esac
152unset system
153#
154GEOMAG=${directory}
155export GEOMAG
156unset directory
157#
158# add GEOMAG tools to PATH
159# if not already done
160echo ${PATH} | grep -q ${GEOMAG}
161test_path=${?}
162if [ ${test_path} -ne 0 ]
163then
164   PATH=${GEOMAG}/:${PATH}
165   export PATH
166else
167   # option bavarde oui/non pas encore implantée ++
168   echo "${command} : iii : ${GEOMAG}/ already in \${PATH}"
169fi
170unset test_path
171#
172# add GEOMAG manuals to MANPATH
173# if not already done
174echo ${MANPATH} | grep -q ${GEOMAG}
175test_manpath=${?}
176if [ ${test_manpath} -ne 0 ]
177then
178   MANPATH=${GEOMAG}/doc/manuals/man/:${MANPATH}
179   export MANPATH
180else
181   # option bavarde oui/non pas encore implantée ++
182   echo "${command} : iii : ${GEOMAG}/doc/manuals/man/ already in \${MANPATH}"
183fi
184unset test_manpath
185#
186GEOMAG_LOG=${tempdir}
187export GEOMAG_LOG
188unset tempdir
189if [ ! -d ${GEOMAG_LOG} ]
190then
191  mkdir -p ${GEOMAG_LOG}
192  echo "${command} : iii : creation of \${GEOMAG_LOG}"
193fi
194# check for permission on GEOMAG_LOG
195if [ ! -x ${GEOMAG_LOG} ]
196then
197 echo " eee : ${GEOMAG_LOG} not reachable"
198 # nb : no exit because this file should be launched by login process
199fi
200#
201# check for permission on GEOMAG_LOG
202if [ ! -w ${GEOMAG_LOG} ]
203then
204 echo " eee : ${GEOMAG_LOG} not writable"
205 # nb : no exit because this file shouldreachable be launched by login process
206fi
207#
208EDITOR=vi
209export EDITOR
210#
211# io directories
212GEOMAG_ID=${indir}
213export GEOMAG_ID
214unset indir
215if [ ! -d ${GEOMAG_ID} ]
216then
217  mkdir -p ${GEOMAG_ID}
218  echo "${command} : iii : creation of \${GEOMAG_ID}"
219fi
220# check for permission on GEOMAG_ID
221if [ ! -x ${GEOMAG_ID} ]
222then
223 echo " eee : ${GEOMAG_ID} not reachable"
224 # nb : no exit because this file should be launched by login process
225fi
226#
227GEOMAG_OD=${outdir}
228export GEOMAG_OD
229unset outdir
230if [ ! -d ${GEOMAG_OD} ]
231then
232  mkdir -p ${GEOMAG_OD}
233  echo "${command} : iii : creation of \${GEOMAG_OD}"
234fi
235# check for permission on GEOMAG_OD
236if [ ! -x ${GEOMAG_OD} ]
237then
238 echo " eee : ${GEOMAG_OD} not reachable"
239 # nb : no exit because this file should be launched by login process
240fi
241if [ ! -w ${GEOMAG_OD} ]
242then
243 echo " eee : ${GEOMAG_OD} not writable"
244 # nb : no exit because this file should be launched by login process
245fi
246#
247# end
248unset command
249# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.