source: trunk/src/project_profile.sh @ 14

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

fix thanks to coding rules; utf8

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 8.0 KB
RevLine 
[2]1#! /bin/sh
2#+
3#
[9]4# .. program:: project_profile.sh
[2]5#
[9]6# .. _project_profile.sh:
[2]7#
[9]8# =============================================
9# project_profile.sh - define POMME environment
10# =============================================
[2]11#
12# SYNOPSIS
13# ========
14#
[12]15# Online usage:
[2]16#
[12]17# .. code-block:: bash
[2]18#
[12]19#    . ./project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir
[2]20#
[12]21# In ${HOME}/.profile, add the following line:
[2]22#
[12]23# .. code-block:: bash
24#
25#    . project_profile.sh -d directory -i indir -o outdir -t tempdir -s saxo_dir
26#
[2]27# DESCRIPTION
28# ===========
29#
30# .. option:: -d  <directory>
31# .. option:: -i  <indir>
32# .. option:: -o  <outdir>
33# .. option:: -t  <tempdir>
[9]34# .. option:: -s  <saxo_dir>
[2]35#
36# define POMME environment
37#
[9]38# ${PROJECT} is the base directory of tools.
[2]39#
[9]40# ${PROJECT_LOG} is the directory where log files will be written.
[2]41#
[9]42# ${PROJECT_ID} is the directory where input files must be.
[2]43#
[9]44# ${PROJECT_OD} is the directory where output files will be written.
[2]45#
[9]46# ${SAXO_DIR} is the base directory of SAXO tools.
[2]47#
[9]48# PATH is completed with ${PROJECT}.
49#
[2]50# SEE ALSO
51# ========
52#
53# for IDL/GDL environment :
54#
[9]55# :ref:`project_init.pro`
56# :ref:`cm_project.pro`
[2]57#
58# EXAMPLES
59# ========
60#
[12]61# For fplod, on aedon.locean-ipsl.upmc.fr:
[2]62#
[12]63# .. code-block:: bash
64#
65#    cd /usr/home/fplod/incas/pomme/pomme_ws/
66#    . ./src/project_profile.sh \
[2]67#    -d $(pwd) \
68#    -i /usr/temp/${LOGNAME}/pomme_d/ \
69#    -o /usr/temp/${LOGNAME}/pomme_d/ \
[9]70#    -t /usr/temp/${LOGNAME}/log/ \
71#    -s /usr/home/fplod/SAXO_DIR/
[2]72#
[12]73# For fplod on cratos.locean-ipsl.umpc.fr:
[2]74#
[12]75# .. code-block:: bash
76#
77#    cd ${HOME}/incas/pomme/pomme_ws/
78#    . ./src/project_profile.sh \
[2]79#    -d $(pwd) \
80#    -i /usr/temp/${LOGNAME}/pomme_d/ \
81#    -o /usr/temp/${LOGNAME}/pomme_d/ \
[9]82#    -t /usr/temp/${LOGNAME}/log/ \
83#    -s ${HOME}/SAXO_DIR/
[2]84#
[12]85# For pinsard on camelot.ipsl.polytechnique.fr or merlin15-c.climserv:
[2]86#
[12]87# .. code-block:: bash
[2]88#
[12]89#    cd ${HOME}/pomme/
90#    . ./src/project_profile.sh \
91#    -d $(pwd) \
92#    -i /homedata/${LOGNAME}/pomme_d/ \
93#    -o /homedata/${LOGNAME}/pomme_d/ \
94#    -t /homedata/${LOGNAME}/log/ \
95#    -s ${HOME}/SAXO_DIR/
96#
[2]97# TODO
98# ====
99#
100# ++ option bavarde
101#
102# ++ machine dependant
103#
104# ++ besoin de posix
105#
[14]106# ++ pas de MANPATH defini par défaut sur cratos et cerbere
[2]107#
108# EVOLUTIONS
109# ==========
110#
[9]111# - fplod 20110426T151058Z cratos.locean-ipsl.upmc.fr (Linux)
112#
[12]113#   * add IDL and SAXO env.
[9]114#   * replace POMME by PROJECT
115#   * replace zeus by cratos
116#
[2]117# - fplod 20101118T171653Z aedon.locean-ipsl.upmc.fr (Darwin)
118#
119#   * creation
120#
121#-
122system=$(uname)
123case "${system}" in
[12]124    AIX|IRIX64)
125        echo " www : no specific posix checking"
126    ;;
127    *)
128        set -o posix
129    ;;
[2]130esac
131unset system
132#
133LANG=C
134#
[10]135set -u
136#
[2]137# as this script might be launch in .profile, command is forced.
[9]138command=project_profile.sh
[2]139#
[9]140usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -s saxo_dir"
[2]141#
[14]142pb=0
[2]143#
[14]144minargcount=10
145maxargcount=10
146narg=${#}
147#
148if [ ${narg} -lt ${minargcount} ]
[2]149then
[14]150    echo "eee : not enought arguments (${narg} vs ${minargcount})"
151    echo "${usage}"
[12]152    # nb : no exit because this file should be launched by login process
[14]153    pb=1
[2]154fi
[14]155unset minargcount
[2]156#
[14]157if [ ${narg} -gt ${maxargcount} ]
[2]158then
[14]159    echo "eee : too many arguments (${narg} vs ${maxargcount})"
160    echo "${usage}"
[12]161    # nb : no exit because this file should be launched by login process
[14]162    pb=1
[2]163fi
[14]164unset maxargcount
165unset narg
[2]166#
[14]167if [ ${pb} -eq 0 ]
[2]168then
[14]169    while [ ${#} -gt 0 ]
170    do
171        case ${1} in
172            -d)
173                # directory for application choosen by user
174                # (see svn checkout command used)
175                directory=${2}
176                shift
177            ;;
178            -i)
179                # directory for inputs choosen by user
180                indir=${2}
181                shift
182            ;;
183            -o)
184                # directory for outputs choosen by user
185                outdir=${2}
186                shift
187            ;;
188            -t)
189                # directory for temporary outputs choosen by user
190                tempdir=${2}
191                shift
192            ;;
193            -s)
194                saxo_dir=${2}
195                shift
196            ;;
197            *)
198                # other choice
199                echo "eee : unknown option ${1}"
200                echo "${usage}"
201                # nb : no exit because this file should be launched
202                # by login process
203            ;;
204        esac
205        # next flag
206        shift
207    done
208    unset usage
[2]209fi
210#
[14]211if [ ${pb} -eq 0 ]
[2]212then
[14]213    # check for ${directory}
214    if [ ! -d ${directory} ]
[12]215    then
[14]216        echo " eee : ${directory} not found"
[12]217        # nb : no exit because this file should be launched by login process
[14]218    fi
219    #
220    # check for permission on directory
221    if [ ! -x ${directory} ]
222    then
223        echo " eee : ${directory} not reachable"
224        # nb : no exit because this file should be launched by login process
225    fi
226    #
227    PROJECT=${directory}
228    export PROJECT
229    unset directory
230    #
231    # add PROJECT tools to PATH
232    # if not already done
233    suppath=$(echo ${PROJECT}/src | tr -s "/")
234    echo ${PATH} | grep -q "${suppath}:"
235    test_path=${?}
236    if [ ${test_path} -ne 0 ]
237    then
238        PATH=${suppath}:${PATH}
239        export PATH
[12]240    else
[14]241        # option bavarde oui/non pas encore implantée ++
242        echo "${command} : iii : ${suppath} already in \${PATH}"
[12]243    fi
[14]244    unset test_path
245    #
246    # add PROJECT manuals to MANPATH
247    # if not already done
248    suppath=$(echo ${PROJECT}/doc/man | tr -s "/")
249    echo ${MANPATH} | grep -q "${suppath}:"
250    test_manpath=${?}
251    if [ ${test_manpath} -ne 0 ]
252    then
253        MANPATH=${suppath}:${MANPATH}
254        export MANPATH
255    else
256        # option bavarde oui/non pas encore implantée ++
257        echo "${command} : iii : ${suppath} already in \${MANPATH}"
258    fi
259    unset test_manpath
260    unset suppath
261    #
262    PROJECT_LOG=${tempdir}
263    export PROJECT_LOG
264    unset tempdir
265    if [ ! -d ${PROJECT_LOG} ]
266    then
267        mkdir -p ${PROJECT_LOG}
268        status=${?}
269        if [ ${status} -ne 0 ]
270        then
271            echo "${command} : eee : can not create \${POMME_LOG}"
272            # nb : no exit because this file should be launched by login process
273        else
274            echo "${command} : iii : creation of \${PROJECT_LOG}"
275        fi
276        unset status
277    fi
278    # check for permission on PROJECT_LOG
279    if [ ! -x ${PROJECT_LOG} ]
280    then
281        echo " eee : ${PROJECT_LOG} not reachable"
282        # nb : no exit because this file should be launched by login process
283    fi
284    #
285    # check for permission on PROJECT_LOG
286    if [ ! -w ${PROJECT_LOG} ]
287    then
288        echo " eee : ${PROJECT_LOG} not writable"
289        # nb : no exit because this file should reachable be launched
290        # by login process
291    fi
292    #
293    EDITOR=vi
294    export EDITOR
295    #
296    # io directories
297    PROJECT_ID=${indir}
298    export PROJECT_ID
299    unset indir
300    if [ ! -d ${PROJECT_ID} ]
301    then
302        mkdir -p ${PROJECT_ID}
303        echo "${command} : iii : creation of \${PROJECT_ID}"
304    fi
305    # check for permission on PROJECT_ID
306    if [ ! -x ${PROJECT_ID} ]
307    then
308        echo " eee : ${PROJECT_ID} not reachable"
309        # nb : no exit because this file should be launched by login process
310    fi
311    #
312    PROJECT_OD=${outdir}
313    export PROJECT_OD
314    unset outdir
315    if [ ! -d ${PROJECT_OD} ]
316    then
317        mkdir -p ${PROJECT_OD}
318        echo "${command} : iii : creation of \${PROJECT_OD}"
319    fi
320    # check for permission on PROJECT_OD
321    if [ ! -x ${PROJECT_OD} ]
322    then
323        echo " eee : ${PROJECT_OD} not reachable"
324        # nb : no exit because this file should be launched by login process
325    fi
326    if [ ! -w ${PROJECT_OD} ]
327    then
328        echo " eee : ${PROJECT_OD} not writable"
329        # nb : no exit because this file should be launched by login process
330    fi
331    #
332    SAXO_DIR=${saxo_dir}
333    export SAXO_DIR
334    #
335    # IDL startup
336    IDL_STARTUP=${PROJECT}/src/project_init.pro
337    export IDL_STARTUP
[2]338fi
[14]339unset pb
[2]340# end
341unset command
342# nb : no exit because this file should be launched by login process
Note: See TracBrowser for help on using the repository browser.