source: trunk/geomag_profile.sh @ 40

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

project homogenization

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