source: trunk/install_superbib.sh @ 144

Last change on this file since 144 was 144, checked in by pinsard, 12 years ago

more realistic dev. guide

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