source: trunk/superbib_profile.sh @ 101

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

improve environnement definition

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