source: trunk/superbib_profile.sh @ 164

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

Consolidation of shell scripts

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