source: trunk/install_superbib.sh @ 325

Last change on this file since 325 was 325, checked in by pinsard, 11 years ago

improvments of doc + some doctest features

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