#! /bin/sh #+ # # .. _ircaam_profile.sh: # # ================= # ircaam_profile.sh # ================= # # ------------------------- # define IRCAAM environment # ------------------------- # # SYNOPSIS # ======== # # Online usage:: # # $ . ./ircaam_profile.sh -d directory -i indir -o outdir -t tempdir # # In :file:`${HOME}/.profile`, add the following line:: # # . ./ircaam_profile.sh -d directory -i indir -o outdir -t tempdir # # DESCRIPTION # =========== # # define IRCAAM environment # # ${IRCAAM} is the source base directory of tools. # # ${IRCAAM_LOG} is the directory where log files will be written. # # ${IRCAAM_ID} is the directory where input files must be. # # ${IRCAAM_OD} is the directory where output files will be written. # # ${IRCAAM}/../bin/ is added to PATH. # # SEE ALSO # ======== # # for matlab/octave environment : # # :ref:`ircaam_startup.m` # # EXAMPLES # ======== # # For fplod, on aedon.locean-ipsl.upmc.fr:: # # $ cd /usr/home/fplod/incas/ircaam/ircaam_ws/ # $ . ./src/ircaam_profile.sh \ # -d $(pwd) \ # -i /usr/temp/${LOGNAME}/ircaam_d/ \ # -o /usr/temp/${LOGNAME}/ircaam_d/ \ # -t /usr/temp/${LOGNAME}/log/ # # For fplod on zeus.locean-ipsl.umpc.fr:: # # $ cd ${HOME}/incas/ircaam/ircaam_ws/ # $ . ./src/ircaam_profile.sh \ # -d $(pwd) \ # -i /usr/temp/${LOGNAME}/ircaam_d/ \ # -o /usr/temp/${LOGNAME}/ircaam_d/ \ # -t /usr/temp/${LOGNAME}/log/ # # TODO # ==== # # ++ option bavarde # # ++ machine dependant # # ++ besoin de posix # # ++ pas de MANPATH defini par défaut sur zeus # # ++ climserv # # EVOLUTIONS # ========== # # $Id$ # # - fplod 20100426T094821Z aedon.locean-ipsl.upmc.fr (Darwin) # # * improve PATH and MANPATH modification # # - fplod 20100423T143244Z aedon.locean-ipsl.upmc.fr (Darwin) # # * add error handling on mkdir # # - fplod 2009-02-17T11:59:35Z aedon.locean-ipsl.upmc.fr (Darwin) # # * more unset statements # # - fplod 2009-02-04T13:35:30Z zeus.locean-ipsl.upmc.fr (Linux) # # * ${IRCAAM}/../bin/ is added to PATH. # # - fplod 2008-08-14T12:28:16Z aedon.locean-ipsl.upmc.fr (Darwin) # # * move all \*.sh and \*.pro files to src/ # # - fplod 2008-07-21T10:58:47Z aedon.locean-ipsl.upmc.fr (Darwin) # # * creation # #- system=$(uname) case "${system}" in AIX|IRIX64) echo " www : no specific posix checking" ;; *) set -o posix ;; esac unset system # set -u # LANG=C # # as this script might be launch in .profile, command is forced. command=ircaam_profile.sh # usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" # while [ ${#} -gt 0 ] 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 # IRCAAM=${directory} export IRCAAM unset directory # # add IRCAAM tools to PATH # if not already done suppath=$(echo ${IRCAAM} | 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 ${IRCAAM}/../bin tools to PATH # if not already done suppath=$(echo ${IRCAAM}/../bin | 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 IRCAAM manuals to MANPATH # if not already done suppath=$(echo ${IRCAAM}/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 # IRCAAM_LOG=${tempdir} export IRCAAM_LOG unset tempdir if [ ! -d ${IRCAAM_LOG} ] then mkdir -p ${IRCAAM_LOG} status=${?} if [ ${status} -ne 0 ] then echo "${command} : eee : can not create \${IRCAAM_LOG}" # nb : no exit because this file should be launched by login process else echo "${command} : iii : creation of \${IRCAAM_LOG}" fi unset status fi # check for permission on IRCAAM_LOG if [ ! -x ${IRCAAM_LOG} ] then echo " eee : ${IRCAAM_LOG} not reachable" # nb : no exit because this file should be launched by login process fi # # check for permission on IRCAAM_LOG if [ ! -w ${IRCAAM_LOG} ] then echo " eee : ${IRCAAM_LOG} not writable" # nb : no exit because this file shouldreachable be launched by login process fi # EDITOR=vi export EDITOR # # io directories IRCAAM_ID=${indir} export IRCAAM_ID unset indir if [ ! -d ${IRCAAM_ID} ] then mkdir -p ${IRCAAM_ID} echo "${command} : iii : creation of \${IRCAAM_ID}" fi # check for permission on IRCAAM_ID if [ ! -x ${IRCAAM_ID} ] then echo " eee : ${IRCAAM_ID} not reachable" # nb : no exit because this file should be launched by login process fi # IRCAAM_OD=${outdir} export IRCAAM_OD unset outdir if [ ! -d ${IRCAAM_OD} ] then mkdir -p ${IRCAAM_OD} echo "${command} : iii : creation of \${IRCAAM_OD}" fi # check for permission on IRCAAM_OD if [ ! -x ${IRCAAM_OD} ] then echo " eee : ${IRCAAM_OD} not reachable" # nb : no exit because this file should be launched by login process fi if [ ! -w ${IRCAAM_OD} ] then echo " eee : ${IRCAAM_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