#! /bin/sh #+ # # .. _superbib_profile.sh: # # =================== # superbib_profile.sh # =================== # # --------------------------- # define SUPERBIB environment # --------------------------- # # SYNOPSIS # ======== # # Online usage :: # # $ . ./superbib_profile.sh -d directory -i indir -o outdir -t tempdir # # In :file:`${HOME}/.profile`, add the following line :: # # . superbib_profile.sh -d directory -i indir -o outdir -t tempdir # # DESCRIPTION # =========== # # .. option:: -d # .. option:: -i # .. option:: -o # .. option:: -t # # define SUPERBIB environment # # ${SUPERBIB} is the base directory of tools. # # ${SUPERBIB_LOG} is the directory where log files will be written. # # ${SUPERBIB_ID} is the directory where input files must be. # # ${SUPERBIB_OD} is the directory where output files will be written. # # MANPATH++ # # EXAMPLES # ======== # # For fplod, on aedon.locean-ipsl.upmc.fr:: # # $ cd /usr/home/fplod/src/superbib/superbib_ws/ # $ . ./src/superbib_profile.sh \ # -d $(pwd) \ # -i /usr/temp/${LOGNAME}/superbib_d/ \ # -o /usr/temp/${LOGNAME}/superbib_d/ \ # -t /usr/temp/${LOGNAME}/log/ # # TODO # ==== # # ++ option bavarde # # ++ machine dependant # # ++ compilateur dependant # # ++ pas de MANPATH defini par defaut sur zeus # # EVOLUTIONS # ========== # # $Id$ # # - fplod 20100426T094821Z aedon.locean-ipsl.upmc.fr (Darwin) # # * improve PATH and MANPATH modification # # - fplod 20100423T144248Z aedon.locean-ipsl.upmc.fr (Darwin) # # * add error handling on mkdir # # - fplod 2008-10-31T11:17:24Z aedon.locean-ipsl.upmc.fr (Darwin) # # * creation ++ pas encore en service # #- system=$(uname) case "${system}" in AIX|IRIX64) echo " www : no specific posix checking" ;; *) set -o posix ;; esac unset system # # as this script might be launch in .profile, command is forced. command=superbib_profile.sh # usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" # set +u while [ ! -z "${1}" ] do case ${1} in -d) # directory for application choosen by user (see svn checkout command used) directory=${2} shift ;; -i) # directory for inputs choosen by user indir=${2} shift ;; -o) # directory for outputs choosen by user outdir=${2} shift ;; -t) # directory for temporary outputs choosen by user tempdir=${2} shift ;; *) # other choice echo "eee : unknown option ${1}" echo "${usage}" # nb : no exit because this file should be launched by login process ;; esac # next flag shift done unset usage # # check for ${directory} if [ ! -d ${directory} ] then echo " eee : ${directory} not found" # nb : no exit because this file should be launched by login process fi # # check for permission on directory if [ ! -x ${directory} ] then echo " eee : ${directory} not reachable" # nb : no exit because this file should be launched by login process fi # SUPERBIB=${directory} export SUPERBIB # # add SUPERBIB tools to PATH # if not already done suppath=$(echo ${SUPERBIB} | tr -s "/") echo ${PATH} | grep -q "${suppath}:" test_path=${?} if [ ${test_path} -ne 0 ] then PATH=${suppath}:${PATH} export PATH else # option bavarde oui/non pas encore implantée ++ echo "${command} : iii : ${suppath} already in \${PATH}" fi unset test_path unset suppath # # add SUPERBIB manuals to MANPATH # if not already done suppath=$(echo ${SUPERBIB}/doc/manuals/man | tr -s "/") echo ${MANPATH} | grep -q "${suppath}:" test_manpath=${?} if [ ${test_manpath} -ne 0 ] then MANPATH=${suppath}:${MANPATH} export MANPATH else # option bavarde oui/non pas encore implantée ++ echo "${command} : iii : ${suppath} already in \${MANPATH}" fi unset test_manpath unset suppath # SUPERBIB_LOG=${tempdir} export SUPERBIB_LOG unset tempdir if [ ! -d ${SUPERBIB_LOG} ] then mkdir -p ${SUPERBIB_LOG} status=${?} if [ ${status} -ne 0 ] then echo "${command} : eee : can not create \${SUPERBIB_LOG}" # nb : no exit because this file should be launched by login process else echo "${command} : iii : creation of \${SUPERBIB_LOG}" fi unset status fi # check for permission on SUPERBIB_LOG if [ ! -x ${SUPERBIB_LOG} ] then echo " eee : ${SUPERBIB_LOG} not reachable" # nb : no exit because this file should be launched by login process fi # # check for permission on SUPERBIB_LOG if [ ! -w ${SUPERBIB_LOG} ] then echo " eee : ${SUPERBIB_LOG} not writable" # nb : no exit because this file shouldreachable be launched by login process fi # EDITOR=vi export EDITOR # # io directories SUPERBIB_ID=${indir} export SUPERBIB_ID unset indir if [ ! -d ${SUPERBIB_ID} ] then mkdir -p ${SUPERBIB_ID} echo "${command} : iii : creation of \${SUPERBIB_ID}" fi # check for permission on SUPERBIB_ID if [ ! -x ${SUPERBIB_ID} ] then echo " eee : ${SUPERBIB_ID} not reachable" # nb : no exit because this file should be launched by login process fi # SUPERBIB_OD=${outdir} export SUPERBIB_OD unset outdir if [ ! -d ${SUPERBIB_OD} ] then mkdir -p ${SUPERBIB_OD} echo "${command} : iii : creation of \${SUPERBIB_OD}" fi # check for permission on SUPERBIB_OD if [ ! -x ${SUPERBIB_OD} ] then echo " eee : ${SUPERBIB_OD} not reachable" # nb : no exit because this file should be launched by login process fi if [ ! -w ${SUPERBIB_OD} ] then echo " eee : ${SUPERBIB_OD} not writable" # nb : no exit because this file should be launched by login process fi # # end unset command # nb : no exit because this file should be launched by login process