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 | #- |
---|
88 | command=$(basename ${0}) |
---|
89 | system=$(uname) |
---|
90 | case "${system}" in |
---|
91 | AIX|IRIX64) |
---|
92 | echo "${command} : www : no specific posix checking" |
---|
93 | ;; |
---|
94 | *) |
---|
95 | set -o posix |
---|
96 | ;; |
---|
97 | esac |
---|
98 | unset system |
---|
99 | # |
---|
100 | set -u |
---|
101 | # |
---|
102 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
103 | # |
---|
104 | # check for ${PROJECT_LOG} definition |
---|
105 | if [ "${PROJECT_LOG}" = "" ] |
---|
106 | then |
---|
107 | echo "${command} : eee : \${PROJECT_LOG} not defined" |
---|
108 | exit 1 |
---|
109 | fi |
---|
110 | # |
---|
111 | # check for ${PROJECT_LOG} existence |
---|
112 | if [ ! -d ${PROJECT_LOG} ] |
---|
113 | then |
---|
114 | echo "${command} : eee : ${PROJECT_LOG} not found" |
---|
115 | exit 1 |
---|
116 | fi |
---|
117 | # |
---|
118 | # check for permission access on PROJECT_LOG |
---|
119 | if [ ! -x ${PROJECT_LOG} ] |
---|
120 | then |
---|
121 | echo "${command} : eee : ${PROJECT_LOG} not reachable" |
---|
122 | exit 1 |
---|
123 | fi |
---|
124 | # |
---|
125 | # check for write permission on PROJECT_LOG |
---|
126 | if [ ! -w ${PROJECT_LOG} ] |
---|
127 | then |
---|
128 | echo "${command} : eee : ${PROJECT_LOG} not writable" |
---|
129 | exit 1 |
---|
130 | fi |
---|
131 | # |
---|
132 | log=${PROJECT_LOG}/$(basename ${command} .sh).log.${log_date} |
---|
133 | # |
---|
134 | usage=" Usage : ${command} -lf loginforgeipsl -d directory" |
---|
135 | # |
---|
136 | # default |
---|
137 | hostname=$(hostname --fqdn) |
---|
138 | make_command=gmake |
---|
139 | svn_forge=1 |
---|
140 | # |
---|
141 | minargcount=0 |
---|
142 | if [ ${#} -lt ${minargcount} ] |
---|
143 | then |
---|
144 | echo "${command} : eee : not enough arguments" |
---|
145 | echo "${usage}" |
---|
146 | exit 1 |
---|
147 | fi |
---|
148 | unset minargcount |
---|
149 | # |
---|
150 | while [ ${#} -gt 0 ] |
---|
151 | do |
---|
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 |
---|
174 | done |
---|
175 | # |
---|
176 | unset usage |
---|
177 | # |
---|
178 | echo "[Context]" 1>> ${log} |
---|
179 | echo "command=${command}" 1>> ${log} |
---|
180 | echo "hostname=${hostname}" 1>> ${log} |
---|
181 | echo "runtime=${log_date}" 1>> ${log} |
---|
182 | # |
---|
183 | echo "" 1>> ${log} |
---|
184 | echo "[Parameters]" 1>> ${log} |
---|
185 | echo "directory=${directory}" 1>> ${log} |
---|
186 | echo "svn_forge=${svn_forge}" 1>> ${log} |
---|
187 | echo "" 1>> ${log} |
---|
188 | # |
---|
189 | # check parameters |
---|
190 | # |
---|
191 | if [ ${svn_forge} -eq 1 ] |
---|
192 | then |
---|
193 | if [ "${loginforgeipsl}" = "" ] |
---|
194 | then |
---|
195 | echo "${command} : eee: loginforgeipsl must be defined" |
---|
196 | exit 1 |
---|
197 | fi |
---|
198 | fi |
---|
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. |
---|
203 | domain=$(nslookup $(hostname) | grep Name: | cut -f 2 | cut -f 2- -d '.') |
---|
204 | case ${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 | ;; |
---|
217 | esac |
---|
218 | unset domain |
---|
219 | # |
---|
220 | project=superbib |
---|
221 | # |
---|
222 | # get files |
---|
223 | if [ -d ${tempdir}/for_install_superbib/ ] |
---|
224 | then |
---|
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 |
---|
243 | else |
---|
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 |
---|
261 | fi |
---|
262 | # |
---|
263 | # installation of files needed |
---|
264 | mkdir -p ${directory}/ |
---|
265 | cp -rp ${tempdir}/for_install_superbib/* ${directory}/ |
---|
266 | # |
---|
267 | echo "${command} : iii : everything you need is under" |
---|
268 | echo "${command} : iii : ${directory}/" |
---|
269 | echo "${command} : iii : log is ${log}" |
---|
270 | # |
---|
271 | # cleaning |
---|
272 | unset log |
---|
273 | #++ |
---|
274 | # |
---|
275 | # end |
---|
276 | exit 0 |
---|