source: trunk/superbib_profile.sh @ 105

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

modif. of headers for manuals hyperlinks improvements

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