source: trunk/superbib_profile.sh @ 109

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

usage of program directive

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