source: trunk/superbib_profile.sh @ 140

Last change on this file since 140 was 116, checked in by pinsard, 13 years ago

Consolidation of shell scripts

  • 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#
97set -u
98#
99# as this script might be launch in .profile, command is forced.
100command=superbib_profile.sh
101#
102usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir"
103#
104while [ ${#} -gt 0 ]
105do
106   case ${1} in
107      -d)
108         # directory for application choosen by user (see svn checkout command used)
109         directory=${2}
110         shift
111      ;;
112      -i)
113         # directory for inputs choosen by user
114         indir=${2}
115         shift
116      ;;
117      -o)
118         # directory for outputs choosen by user
119         outdir=${2}
120         shift
121      ;;
122      -t)
123         # directory for temporary outputs choosen by user
124         tempdir=${2}
125         shift
126      ;;
127      *)
128         # other choice
129        echo "eee : unknown option ${1}"
130        echo "${usage}"
131        # nb : no exit because this file should be launched by login process
132      ;;
133   esac
134   # next flag
135   shift
136done
137unset usage
138#
139# check for ${directory}
140if [ ! -d ${directory} ]
141then
142   echo " eee : ${directory} not found"
143   # nb : no exit because this file should be launched by login process
144fi
145#
146# check for permission on directory
147if [ ! -x ${directory} ]
148then
149   echo " eee : ${directory} not reachable"
150   # nb : no exit because this file should be launched by login process
151fi
152#
153SUPERBIB=${directory}
154export SUPERBIB
155#
156# add SUPERBIB tools to PATH
157# if not already done
158suppath=$(echo ${SUPERBIB} | tr -s "/")
159echo ${PATH} | grep -q "${suppath}:"
160test_path=${?}
161if [ ${test_path} -ne 0 ]
162then
163   PATH=${suppath}:${PATH}
164   export PATH
165else
166   # option bavarde oui/non pas encore implantée ++
167   echo "${command} : iii : ${suppath} already in \${PATH}"
168fi
169unset test_path
170unset suppath
171#
172# add SUPERBIB manuals to MANPATH
173# if not already done
174suppath=$(echo ${SUPERBIB}/doc/manuals/man | tr -s "/")
175echo ${MANPATH} | grep -q "${suppath}:"
176test_manpath=${?}
177if [ ${test_manpath} -ne 0 ]
178then
179   MANPATH=${suppath}:${MANPATH}
180   export MANPATH
181else
182   # option bavarde oui/non pas encore implantée ++
183   echo "${command} : iii : ${suppath} already in \${MANPATH}"
184fi
185unset test_manpath
186unset suppath
187#
188SUPERBIB_LOG=${tempdir}
189export SUPERBIB_LOG
190unset tempdir
191if [ ! -d ${SUPERBIB_LOG} ]
192then
193   mkdir -p ${SUPERBIB_LOG}
194   status=${?}
195   if [ ${status} -ne 0 ]
196   then
197      echo "${command} : eee : can not create \${SUPERBIB_LOG}"
198      # nb : no exit because this file should be launched by login process
199   else
200      echo "${command} : iii : creation of \${SUPERBIB_LOG}"
201   fi
202   unset status
203fi
204# check for permission on SUPERBIB_LOG
205if [ ! -x ${SUPERBIB_LOG} ]
206then
207   echo " eee : ${SUPERBIB_LOG} not reachable"
208   # nb : no exit because this file should be launched by login process
209fi
210#
211# check for permission on SUPERBIB_LOG
212if [ ! -w ${SUPERBIB_LOG} ]
213then
214   echo " eee : ${SUPERBIB_LOG} not writable"
215   # nb : no exit because this file shouldreachable be launched by login process
216fi
217#
218EDITOR=vi
219export EDITOR
220#
221# io directories
222SUPERBIB_ID=${indir}
223export SUPERBIB_ID
224unset indir
225if [ ! -d ${SUPERBIB_ID} ]
226then
227   mkdir -p ${SUPERBIB_ID}
228   echo "${command} : iii : creation of \${SUPERBIB_ID}"
229fi
230# check for permission on SUPERBIB_ID
231if [ ! -x ${SUPERBIB_ID} ]
232then
233   echo " eee : ${SUPERBIB_ID} not reachable"
234   # nb : no exit because this file should be launched by login process
235fi
236#
237SUPERBIB_OD=${outdir}
238export SUPERBIB_OD
239unset outdir
240if [ ! -d ${SUPERBIB_OD} ]
241then
242    mkdir -p ${SUPERBIB_OD}
243    echo "${command} : iii : creation of \${SUPERBIB_OD}"
244fi
245# check for permission on SUPERBIB_OD
246if [ ! -x ${SUPERBIB_OD} ]
247then
248   echo " eee : ${SUPERBIB_OD} not reachable"
249   # nb : no exit because this file should be launched by login process
250fi
251if [ ! -w ${SUPERBIB_OD} ]
252then
253   echo " eee : ${SUPERBIB_OD} not writable"
254   # nb : no exit because this file should be launched by login process
255fi
256#
257# end
258unset command
259# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.