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 | #- |
---|
80 | command=$(basename ${0}) |
---|
81 | system=$(uname) |
---|
82 | case "${system}" in |
---|
83 | AIX|IRIX64) |
---|
84 | echo "${command} : www : no specific posix checking" |
---|
85 | ;; |
---|
86 | *) |
---|
87 | set -o posix |
---|
88 | ;; |
---|
89 | esac |
---|
90 | unset system |
---|
91 | # |
---|
92 | set -u |
---|
93 | # |
---|
94 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
95 | # |
---|
96 | # check for ${PROJECT_LOG} definition |
---|
97 | if [ "${PROJECT_LOG}" = "" ] |
---|
98 | then |
---|
99 | echo "${command} : eee : \${PROJECT_LOG} not defined" |
---|
100 | exit 1 |
---|
101 | fi |
---|
102 | # |
---|
103 | # check for ${PROJECT_LOG} existence |
---|
104 | if [ ! -d ${PROJECT_LOG} ] |
---|
105 | then |
---|
106 | echo "${command} : eee : ${PROJECT_LOG} not found" |
---|
107 | exit 1 |
---|
108 | fi |
---|
109 | # |
---|
110 | # check for permission access on PROJECT_LOG |
---|
111 | if [ ! -x ${PROJECT_LOG} ] |
---|
112 | then |
---|
113 | echo "${command} : eee : ${PROJECT_LOG} not reachable" |
---|
114 | exit 1 |
---|
115 | fi |
---|
116 | # |
---|
117 | # check for write permission on PROJECT_LOG |
---|
118 | if [ ! -w ${PROJECT_LOG} ] |
---|
119 | then |
---|
120 | echo "${command} : eee : ${PROJECT_LOG} not writable" |
---|
121 | exit 1 |
---|
122 | fi |
---|
123 | # |
---|
124 | log=${PROJECT_LOG}/$(basename ${command} .sh).log.${log_date} |
---|
125 | # |
---|
126 | usage=" Usage : ${command} -lf loginforgeipsl -d directory" |
---|
127 | # |
---|
128 | # default |
---|
129 | hostname=$(hostname --fqdn) |
---|
130 | make_command=gmake |
---|
131 | svn_forge=1 |
---|
132 | # |
---|
133 | minargcount=0 |
---|
134 | if [ ${#} -lt ${minargcount} ] |
---|
135 | then |
---|
136 | echo "${command} : eee : not enought arguments" |
---|
137 | echo "${usage}" |
---|
138 | exit 1 |
---|
139 | fi |
---|
140 | unset minargcount |
---|
141 | # |
---|
142 | while [ ${#} -gt 0 ] |
---|
143 | do |
---|
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 |
---|
166 | done |
---|
167 | # |
---|
168 | unset usage |
---|
169 | # |
---|
170 | echo "[Context]" 1>> ${log} |
---|
171 | echo "command=${command}" 1>> ${log} |
---|
172 | echo "hostname=${hostname}" 1>> ${log} |
---|
173 | echo "runtime=${log_date}" 1>> ${log} |
---|
174 | # |
---|
175 | echo "" 1>> ${log} |
---|
176 | echo "[Parameters]" 1>> ${log} |
---|
177 | echo "directory=${directory}" 1>> ${log} |
---|
178 | echo "svn_forge=${svn_forge}" 1>> ${log} |
---|
179 | echo "" 1>> ${log} |
---|
180 | # |
---|
181 | # check parameters |
---|
182 | # |
---|
183 | if [ ${svn_forge} -eq 1 ] |
---|
184 | then |
---|
185 | if [ "${loginforgeipsl}" = "" ] |
---|
186 | then |
---|
187 | echo "${command} : eee: loginforgeipsl must be defined" |
---|
188 | exit 1 |
---|
189 | fi |
---|
190 | fi |
---|
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. |
---|
195 | domain=$(nslookup $(hostname) | grep Name: | cut -f 2 | cut -f 2- -d '.') |
---|
196 | case ${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 | ;; |
---|
209 | esac |
---|
210 | unset domain |
---|
211 | # |
---|
212 | project=superbib |
---|
213 | # |
---|
214 | # get files |
---|
215 | if [ -d ${tempdir}/for_install_superbib/ ] |
---|
216 | then |
---|
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 |
---|
235 | else |
---|
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 |
---|
253 | fi |
---|
254 | # |
---|
255 | # installation of files needed |
---|
256 | mkdir -p ${directory}/ |
---|
257 | cp -rp ${tempdir}/for_install_superbib/* ${directory}/ |
---|
258 | # |
---|
259 | echo "${command} : iii : everything you need is under" |
---|
260 | echo "${command} : iii : ${directory}/" |
---|
261 | echo "${command} : iii : log is ${log}" |
---|
262 | # |
---|
263 | # cleaning |
---|
264 | unset log |
---|
265 | #++ |
---|
266 | # |
---|
267 | # end |
---|
268 | exit 0 |
---|