source: trunk/install_superbib.sh

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