source: trunk/install_superbib.sh @ 352

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

fix thanks to coding rules; typo

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.9 KB
Line 
1#! /bin/sh -x
2#+
3#
4# .. program:: install_superbib.sh
5#
6# .. _install_superbib.sh:
7#
8# ===================
9# install_superbib.sh
10# ===================
11#
12# DESCRIPTION
13# ===========
14#
15# installation of project
16#
17# SYNOPSIS
18# ========
19#
20# .. code-block:: sh
21#
22#    install_superbib.sh -lf loginforgeipsl -d directory
23#
24# DESCRIPTION
25# ===========
26#
27# .. option:: -lf  <login on forge.ipsl.jussieu.fr>
28#
29# .. option:: -d   <directory>
30#
31#    where executable, input and output will be written
32#
33# On the first usage of this tool, :file:`${tempdir}/for_install_superbib/`
34# will be created.
35# svn forge will be checked out in this directory.
36#
37# On locean-ipsl.upmc.fr, :file:`${tempdir}` is set to
38# :file:`/usr/temp/${LOGNAME}/`.
39#
40# Elsewhere, :file:`${tempdir}` is set to :file:`/tmp/${LOGNAME}/`.
41#
42# ++Once done, experience can be launched using :ref:`project_run.sh`.
43#
44# ++To reset everything, you need to manualy remove :file:`${tempdir}/for_install_superbib/`.
45#
46# ++Log file is written on
47# :file:`${PROJECT_LOG}/install_superbib.sh.log.{YYYYMMDDTHHMMSSZ}`.
48#
49# CAUTIONS
50# ========
51#
52# Must be launch interactively because of password issue.
53#
54# EXAMPLES
55# ========
56#
57# For installation on cratos
58#
59# .. code-block:: sh
60#
61#    install_superbib.sh \
62#    -lf pinsard \
63#    -d ${HOME}/SUPERBIB/
64#
65# SEE ALSO
66# ========
67#
68# :ref:`install`
69#
70# TODO
71# ====
72#
73# ipsl climserv
74
75# EVOLUTIONS
76# ==========
77#
78# $Id: install_superbib.sh 106 2011-12-20 16:20:29Z pinsard $
79#
80# $URL$
81#
82# - fplod 20120227
83#
84#   * creation
85#
86#-
87command=$(basename ${0})
88system=$(uname)
89case "${system}" in
90    AIX|IRIX64)
91        echo "${command} : www : no specific posix checking"
92    ;;
93    *)
94        set -o posix
95    ;;
96esac
97unset system
98#
99set -u
100#
101log_date=$(date -u +"%Y%m%dT%H%M%SZ")
102#
103# check for ${PROJECT_LOG} definition
104if [ "${PROJECT_LOG}" = "" ]
105then
106    echo "${command} : eee : \${PROJECT_LOG} not defined"
107    exit 1
108fi
109#
110# check for ${PROJECT_LOG} existence
111if [ ! -d ${PROJECT_LOG} ]
112then
113    echo "${command} : eee : ${PROJECT_LOG} not found"
114    exit 1
115fi
116#
117# check for permission access on PROJECT_LOG
118if [ ! -x ${PROJECT_LOG} ]
119then
120    echo "${command} : eee : ${PROJECT_LOG} not reachable"
121    exit 1
122fi
123#
124# check for write permission on PROJECT_LOG
125if [ ! -w ${PROJECT_LOG} ]
126then
127    echo "${command} : eee : ${PROJECT_LOG} not writable"
128    exit 1
129fi
130#
131log=${PROJECT_LOG}/$(basename ${command} .sh).log.${log_date}
132#
133usage=" Usage : ${command} -lf loginforgeipsl -d directory"
134#
135# default
136hostname=$(hostname --fqdn)
137make_command=gmake
138svn_forge=1
139#
140minargcount=0
141if [ ${#} -lt ${minargcount} ]
142then
143    echo "${command} : eee : not enough arguments"
144    echo "${usage}"
145    exit 1
146fi
147unset minargcount
148#
149while [ ${#} -gt 0 ]
150do
151    case ${1} in
152        -lf)
153            loginforgeipsl=${2}
154            shift
155        ;;
156        -h)
157            hostname=${2}
158            shift
159        ;;
160        -d)
161            directory=${2}
162            shift
163        ;;
164        *)
165            # anything else
166            echo "${command} : eee : unknown option ${1}"
167            echo "${command} : eee : ${usage}"
168            exit 1
169        ;;
170    esac
171    # next flag
172    shift
173done
174#
175unset usage
176#
177echo "[Context]" 1>> ${log}
178echo "command=${command}" 1>> ${log}
179echo "hostname=${hostname}" 1>> ${log}
180echo "runtime=${log_date}" 1>> ${log}
181#
182echo "" 1>> ${log}
183echo "[Parameters]" 1>> ${log}
184echo "directory=${directory}" 1>> ${log}
185echo "svn_forge=${svn_forge}" 1>> ${log}
186echo "" 1>> ${log}
187#
188# check parameters
189#
190if [ ${svn_forge} -eq 1 ]
191then
192    if [ "${loginforgeipsl}" = "" ]
193    then
194        echo "${command} : eee: loginforgeipsl must be defined"
195        exit 1
196    fi
197fi
198#
199# define tempdir where the tar file will be put and compilation done
200# set if local svn will be used for checkout cdf sources files
201# it can not be so on IDRIS.
202domain=$(nslookup $(hostname) | grep Name: | cut -f 2 | cut -f 2- -d '.')
203case ${domain} in
204    locean-ipsl.upmc.fr)
205        tempdir=/usr/temp/${LOGNAME}/
206        local_svncfd=1
207    ;;
208    idris.fr)
209        tempdir=${WORKDIR}/
210        local_svncfd=0
211    ;;
212   *)
213       tempdir=/tmp/${LOGNAME}/
214       local_svncfd=1
215   ;;
216esac
217unset domain
218#
219project=superbib
220#
221# get files
222if [ -d ${tempdir}/for_install_superbib/ ]
223then
224    # If ${tempdir}/for_install_superbib/ exists, we suppose it already
225    # contains files.
226    if [ ${svn_forge} -eq 1 ]
227    then
228        # We ask for update this working space
229        echo "${command} : iii : ${tempdir}/for_install_superbib/ already exists" 1>> ${log} 2>&1
230        echo "iii : You will be asked ${loginforgeipsl}@forge.ipsl.jussieu.fr passwd"
231        svn update ${tempdir}/for_install_superbib/
232        svn_status=${?}
233        if [ ${svn_status} -ne 0 ]
234        then
235            echo "${command} : eee : pb with svn update forge" 1>> ${log} 2>&1
236            echo "${command} : iii : log is ${log}"
237            exit 1
238        fi
239    else
240        echo "${command} : iii : no svn forge update is asked" 1>> ${log} 2>&1
241    fi
242else
243    mkdir -p ${tempdir}/for_install_superbib/
244    if [ ${svn_forge} -eq 1 ]
245    then
246        # If ${tempdir}/for_install_superbib/ does not exist, we checkout
247        # files
248        echo "iii : You will be asked ${loginforgeipsl}@forge.ipsl.jussieu.fr passwd"
249        svn checkout svn+ssh://${loginforgeipsl}@forge.ipsl.jussieu.fr/ipsl/forge/projets/${project}/svn/trunk/ ${tempdir}/for_install_superbib/ 1>> ${log} 2>&1
250        svn_status=${?}
251        if [ ${svn_status} -ne 0 ]
252        then
253            echo "${command} : eee : pb with svn forge" 1>> ${log} 2>&1
254            echo "${command} : iii : log is ${log}"
255            exit 1
256        fi
257    else
258        echo "${command} : iii : no svn forge checkout is asked" 1>> ${log} 2>&1
259    fi
260fi
261#
262# installation of files needed
263mkdir -p ${directory}/
264cp -rp ${tempdir}/for_install_superbib/* ${directory}/
265#
266echo "${command} : iii : everything you need is under"
267echo "${command} : iii : ${directory}/"
268echo "${command} : iii : log is ${log}"
269#
270# cleaning
271unset log
272#++
273#
274# end
275exit 0
Note: See TracBrowser for help on using the repository browser.