source: trunk/superbib_profile.sh @ 108

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

usage of option directive

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