1 | #! /bin/csh |
---|
2 | # |
---|
3 | # file install.csh |
---|
4 | # =========== |
---|
5 | # |
---|
6 | # version 4, 18-Jun-2006 |
---|
7 | # |
---|
8 | # Installation script for SH/SHM package |
---|
9 | # K. Stammler, 13-Nov-2003 |
---|
10 | |
---|
11 | set ext="undefined" |
---|
12 | if ("`uname`" == "Linux") then |
---|
13 | set ext="linux" |
---|
14 | else if ("`uname`" == "SunOS") then |
---|
15 | set ext="sol2.5.1" |
---|
16 | endif |
---|
17 | |
---|
18 | if ("$1" == "") then |
---|
19 | echo "Usage: $0 <installpath> [<sourcepath>]" |
---|
20 | echo "" |
---|
21 | echo " Steps to install are:" |
---|
22 | echo " (i) create installation directory (e.g. 'mkdir $PWD/shprog')" |
---|
23 | echo " (ii) create tar file directory (e.g. 'mkdir $PWD/shtar')" |
---|
24 | echo " (iii) cd to tar file directory and get files:" |
---|
25 | echo " ftp://ftp.szgrf.bgr.de/pub/software/SH-SHM.tar.gz" |
---|
26 | echo " ftp://ftp.szgrf.bgr.de/pub/software/fk-$ext.tar.gz" |
---|
27 | echo " ftp://ftp.szgrf.bgr.de/pub/software/locsat-$ext.tar.gz" |
---|
28 | echo " ftp://ftp.szgrf.bgr.de/pub/software/SHM-install.csh" |
---|
29 | echo " (iv) make SHM-install.csh executable 'chmod a+x ./SHM-install.csh'" |
---|
30 | echo " (v) call e.g. './SHM-install.csh $PWD/shprog'" |
---|
31 | echo " Note that the parameter must be the absolute path to the" |
---|
32 | echo " installation directory" |
---|
33 | echo "" |
---|
34 | echo -n "Do you want run run the installation now ? [y/n] " |
---|
35 | set reply="$<" |
---|
36 | if ("$reply" == "y" || "$reply" == "Y") then |
---|
37 | set res=`which wget` |
---|
38 | if (! -e $res) then |
---|
39 | echo "need 'wget' to continue. Please install" |
---|
40 | exit |
---|
41 | endif |
---|
42 | echo -n "Where should SH/SHM be installed? Enter full pathname: " |
---|
43 | set dstpath="$<" |
---|
44 | if (! -d $dstpath) mkdir $dstpath |
---|
45 | if (! -w $dstpath) then |
---|
46 | echo "Cannot write to $dstpath. Abort." |
---|
47 | exit |
---|
48 | endif |
---|
49 | set srcpath=$HOME/shpackage |
---|
50 | if (-d $srcpath) then |
---|
51 | echo "SH package directory $srcpath already exists." |
---|
52 | echo "Please rename or delete it and restart the installation program." |
---|
53 | exit |
---|
54 | endif |
---|
55 | echo -n "Create SH package directory $srcpath ? [y/n] " |
---|
56 | set reply="$<" |
---|
57 | if ("$reply" == "y" || "$reply" == "Y") then |
---|
58 | mkdir $srcpath |
---|
59 | else |
---|
60 | exit |
---|
61 | endif |
---|
62 | echo "download SH/SHM package" |
---|
63 | (cd $srcpath; wget ftp://ftp.szgrf.bgr.de/pub/software/SH-SHM.tar.gz) |
---|
64 | echo "download FK package" |
---|
65 | (cd $srcpath; wget ftp://ftp.szgrf.bgr.de/pub/software/fk-$ext.tar.gz) |
---|
66 | echo "download LocSAT package" |
---|
67 | (cd $srcpath; wget ftp://ftp.szgrf.bgr.de/pub/software/locsat-$ext.tar.gz) |
---|
68 | else |
---|
69 | exit |
---|
70 | endif |
---|
71 | |
---|
72 | else |
---|
73 | |
---|
74 | # get parameters |
---|
75 | set dstpath=$1 |
---|
76 | set srcpath=$2 |
---|
77 | if ("$srcpath" == "") set srcpath=$PWD |
---|
78 | |
---|
79 | endif |
---|
80 | |
---|
81 | # check parameters |
---|
82 | if (! -d $srcpath) then |
---|
83 | echo "$0 : source path $srcpath not found. Abort." |
---|
84 | exit |
---|
85 | endif |
---|
86 | if (! -w $dstpath) then |
---|
87 | echo "$0 : cannot write to installation path $dstpath. Abort." |
---|
88 | exit |
---|
89 | endif |
---|
90 | if ("$srcpath" == "$dstpath") then |
---|
91 | echo "$0 : source path and installation path must not be equal. Sorry." |
---|
92 | exit |
---|
93 | endif |
---|
94 | |
---|
95 | # find input files |
---|
96 | set pack_shm="" |
---|
97 | set pack_fk="" |
---|
98 | set pack_locsat="" |
---|
99 | |
---|
100 | if (-e $srcpath/SH-SHM.tar.gz) then |
---|
101 | set pack_shm=$srcpath/SH-SHM.tar.gz |
---|
102 | else |
---|
103 | set pack_shm=`ls $srcpath/SH-* | tail -1` |
---|
104 | endif |
---|
105 | if ("`uname`" == "Linux") then |
---|
106 | if (-e $srcpath/fk-linux.tar.gz) set pack_fk=$srcpath/fk-linux.tar.gz |
---|
107 | if (-e $srcpath/locsat-linux.tar.gz) set pack_locsat=$srcpath/locsat-linux.tar.gz |
---|
108 | else if ("`uname`" == "SunOS") then |
---|
109 | if (-e $srcpath/fk-sol2.5.1.tar.gz) set pack_fk=$srcpath/fk-sol2.5.1.tar.gz |
---|
110 | if (-e $srcpath/locsat-sol2.5.1.tar.gz) set pack_locsat=$srcpath/locsat-sol2.5.1.tar.gz |
---|
111 | else |
---|
112 | endif |
---|
113 | |
---|
114 | if (-e $srcpath/libahio.a.$ext) then |
---|
115 | set use_ah=1 |
---|
116 | else |
---|
117 | set use_ah=0 |
---|
118 | endif |
---|
119 | |
---|
120 | |
---|
121 | # default values |
---|
122 | set compile_shm="yes" |
---|
123 | set compile_fk="no" |
---|
124 | set compile_locsat="no" |
---|
125 | set displ_res="undef" |
---|
126 | set userroot='$HOME/shfiles' |
---|
127 | if ("`uname`" == "Linux") then |
---|
128 | set linux_colors="yes" |
---|
129 | else |
---|
130 | set linux_colors="no" |
---|
131 | endif |
---|
132 | |
---|
133 | # find text editor |
---|
134 | set editor="" |
---|
135 | foreach ed (kate gedit textedit nedit vuepad xedit) |
---|
136 | set res=`which $ed` |
---|
137 | if (-e "$res") then |
---|
138 | set editor=$ed |
---|
139 | break |
---|
140 | endif |
---|
141 | end |
---|
142 | |
---|
143 | # check for some programs in search path |
---|
144 | set plist = ( gzip make makedepend gcc uil ar ranlib xterm ) |
---|
145 | foreach p ($plist) |
---|
146 | set res=`which $p` |
---|
147 | if (! -e "$res") then |
---|
148 | echo "Program $p not found in search path. Please add." |
---|
149 | exit |
---|
150 | endif |
---|
151 | end |
---|
152 | |
---|
153 | # enter setup menu |
---|
154 | |
---|
155 | set cmd="" |
---|
156 | while ("$cmd" != "i") |
---|
157 | |
---|
158 | echo "" |
---|
159 | echo "(p) SHM-package: $pack_shm" |
---|
160 | echo "(f) FK-package: $pack_fk" |
---|
161 | echo "(l) LocSAT-package: $pack_locsat" |
---|
162 | echo "(u) user root path: $userroot" |
---|
163 | echo "(e) window based texteditor: $editor" |
---|
164 | echo "(cp) compile SHM: $compile_shm" |
---|
165 | echo "(cf) compile FK: $compile_fk" |
---|
166 | echo "(cl) compile LocSAT: $compile_locsat" |
---|
167 | # echo "(r) resolution: $displ_res" |
---|
168 | echo "(c) linux colors: $linux_colors" |
---|
169 | echo "(i) Start Installation" |
---|
170 | echo "(q) Quit Installation" |
---|
171 | echo "" |
---|
172 | echo "if all settings are ok, enter 'i'" |
---|
173 | echo "" |
---|
174 | echo -n "cmd: " |
---|
175 | set cmd="$<" |
---|
176 | |
---|
177 | if ("$cmd" == "q") exit |
---|
178 | if ("$cmd" == "p") then |
---|
179 | echo -n "SHM-package: " |
---|
180 | set pack_shm="$<" |
---|
181 | endif |
---|
182 | if ("$cmd" == "f") then |
---|
183 | echo -n "FK-package: " |
---|
184 | set pack_fk="$<" |
---|
185 | endif |
---|
186 | if ("$cmd" == "l") then |
---|
187 | echo -n "LocSAT-package: " |
---|
188 | set pack_locsat="$<" |
---|
189 | endif |
---|
190 | if ("$cmd" == "cp") then |
---|
191 | if ("$compile_shm" == "yes") then |
---|
192 | set compile_shm="no" |
---|
193 | else |
---|
194 | set compile_shm="yes" |
---|
195 | endif |
---|
196 | endif |
---|
197 | if ("$cmd" == "cf") then |
---|
198 | if ("$compile_fk" == "yes") then |
---|
199 | set compile_fk="no" |
---|
200 | else |
---|
201 | set compile_fk="yes" |
---|
202 | endif |
---|
203 | endif |
---|
204 | if ("$cmd" == "cl") then |
---|
205 | if ("$compile_locsat" == "yes") then |
---|
206 | set compile_locsat="no" |
---|
207 | else |
---|
208 | set compile_locsat="yes" |
---|
209 | endif |
---|
210 | endif |
---|
211 | if ("$cmd" == "r") then |
---|
212 | if ("$displ_res" == "xga") then |
---|
213 | set displ_res="wxga" |
---|
214 | else if ("$displ_res" == "wxga") then |
---|
215 | set displ_res="sxga" |
---|
216 | else |
---|
217 | set displ_res="xga" |
---|
218 | endif |
---|
219 | endif |
---|
220 | if ("$cmd" == "c") then |
---|
221 | if ("$linux_colors" == "yes") then |
---|
222 | set linux_colors="no" |
---|
223 | else |
---|
224 | set linux_colors="yes" |
---|
225 | endif |
---|
226 | endif |
---|
227 | if ("$cmd" == "e") then |
---|
228 | echo -n "window based texteditor: " |
---|
229 | set editor="$<" |
---|
230 | if (! -e $editor) then |
---|
231 | echo "$editor does not exist." |
---|
232 | echo -n "Enter <Return> ..." |
---|
233 | set x="$<" |
---|
234 | set editor="" |
---|
235 | endif |
---|
236 | endif |
---|
237 | if ("$cmd" == "u") then |
---|
238 | echo -n "user root path: " |
---|
239 | set userroot="$<" |
---|
240 | if (! -e $userroot) then |
---|
241 | mkdir $userroot |
---|
242 | if (! -e $userroot) then |
---|
243 | echo "cannot create $userroot. Reset to default." |
---|
244 | echo -n "Enter <Return> ..." |
---|
245 | set x="$<" |
---|
246 | set userroot=$HOME/shfiles |
---|
247 | endif |
---|
248 | endif |
---|
249 | endif |
---|
250 | if ("$cmd" == "i") then |
---|
251 | if ("$editor" == "") then |
---|
252 | echo "Please specify window based texteditor executable." |
---|
253 | echo -n "Enter <Return> ..." |
---|
254 | set x="$<" |
---|
255 | set cmd="." |
---|
256 | endif |
---|
257 | endif |
---|
258 | |
---|
259 | end |
---|
260 | |
---|
261 | |
---|
262 | # check paths again |
---|
263 | if (! -e $pack_shm) then |
---|
264 | echo "$0 : echo SHM-package $pack_shm not found. Abort." |
---|
265 | exit |
---|
266 | endif |
---|
267 | if (! -e $pack_fk) then |
---|
268 | echo "$0 : FK-package not found. Abort." |
---|
269 | exit |
---|
270 | endif |
---|
271 | if (! -e $pack_locsat) then |
---|
272 | echo "$0 : LocSAT-package not found. Abort." |
---|
273 | exit |
---|
274 | endif |
---|
275 | |
---|
276 | cd $dstpath |
---|
277 | |
---|
278 | # create setup file from template |
---|
279 | echo "prepare setup file" |
---|
280 | cd sh/setup |
---|
281 | if ("`uname`" == "Linux") then |
---|
282 | set remstr="#OS-linux " |
---|
283 | else if ("`uname`" == "SunOS") then |
---|
284 | set remstr="#OS-sol2 " |
---|
285 | else |
---|
286 | echo "$0 : sorry, this operating system is not supported" |
---|
287 | exit |
---|
288 | endif |
---|
289 | set locsatpath=$dstpath/sh/util/locsat |
---|
290 | set plth=`echo $locsatpath | wc -c` |
---|
291 | if ($plth > 25) then |
---|
292 | if (-e $HOME/lcs) \rm $HOME/lcs |
---|
293 | ln -s $locsatpath $HOME/lcs |
---|
294 | set locsatpath=$HOME/lcs |
---|
295 | set plth=`echo $locsatpath | wc -c` |
---|
296 | if ($plth > 25) then |
---|
297 | echo "$0 : cannot find short locsat path. Abort." |
---|
298 | exit |
---|
299 | endif |
---|
300 | endif |
---|
301 | if (-e shsetup) \rm shsetup |
---|
302 | sed "s/$remstr//" shsetup.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \ |
---|
303 | sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \ |
---|
304 | sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" >shsetup |
---|
305 | if ($use_ah == 0) then |
---|
306 | if (-e shsetup.x) \rm shsetup.x |
---|
307 | sed 's/-DSH_SETUP_AH//' shsetup | sed 's/-lahio//' >shsetup.x |
---|
308 | \rm shsetup |
---|
309 | mv shsetup.x shsetup |
---|
310 | endif |
---|
311 | if ($?MACHTYPE == 1) then |
---|
312 | if ("`echo $MACHTYPE | grep 64`" != "") then |
---|
313 | if (-d /usr/X11R6/lib64) then |
---|
314 | if (-e shsetup.x) \rm shsetup.x |
---|
315 | sed 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup >shsetup.x |
---|
316 | \rm shsetup |
---|
317 | mv shsetup.x shsetup |
---|
318 | endif |
---|
319 | endif |
---|
320 | endif |
---|
321 | source shsetup |
---|
322 | |
---|
323 | # create directories for evt files |
---|
324 | mkdir $SH_USERROOT/evt |
---|
325 | mkdir $SH_USERROOT/evt/evid |
---|
326 | mkdir $SH_USERROOT/evt/evtout |
---|
327 | |
---|
328 | # find screen resolution |
---|
329 | set displ_res=`$dstpath/sh/util/get_screen_resolution.csh` |
---|
330 | if ($#displ_res != 3) then |
---|
331 | echo "cannot find screen resolution, please set manually" |
---|
332 | set displ_res="sxga" |
---|
333 | else |
---|
334 | echo "found screen resolution $displ_res" |
---|
335 | set displ_res=$displ_res[3] |
---|
336 | endif |
---|
337 | |
---|
338 | set origsetup=$dstpath/sh/inputs/shm-config-default.txt |
---|
339 | if (! -e $origsetup) then |
---|
340 | echo "Installation program error. Sorry." |
---|
341 | exit |
---|
342 | endif |
---|
343 | set thissetup=$dstpath/sh/inputs/shm-config.txt |
---|
344 | if (-e $thissetup) \rm $thissetup |
---|
345 | cp $origsetup $thissetup |
---|
346 | |
---|
347 | # settings for small displays (laptops) |
---|
348 | if ("$displ_res" != "" && "$displ_res" != "sxga") then |
---|
349 | if (-e $thissetup.x) \rm $thissetup.x |
---|
350 | sed "s/shm-cof-sxga-geometry/shm-conf-$displ_res-geometry/" $thissetup >$thissetup.x |
---|
351 | mv $thissetup.x $thissetup |
---|
352 | endif |
---|
353 | |
---|
354 | # linux colors |
---|
355 | if ("$linux_colors" == "yes") then |
---|
356 | # do nothing, this is default |
---|
357 | else |
---|
358 | if (-e $thissetup.x) \rm $thissetup.x |
---|
359 | sed 's/reverse_xors true/reverse_xors false/' $thissetup>$thisetup.x |
---|
360 | mv $thissetup.x $thissetup |
---|
361 | endif |
---|
362 | |
---|
363 | # compile SHM |
---|
364 | if ("$compile_shm" == "yes") then |
---|
365 | echo "compiling SHM" |
---|
366 | cd $SH_ROOT |
---|
367 | # remove all o's and a's |
---|
368 | set olist=`find . -name \*.o -print` |
---|
369 | \rm $olist |
---|
370 | cd $SH_LIB |
---|
371 | if (-e libahio.a) mv libahio.a libahio.ax |
---|
372 | \rm *.a |
---|
373 | if (-e libahio.ax) mv libahio.ax libahio.a |
---|
374 | cd $SH_ROOT |
---|
375 | make depend_shm |
---|
376 | make shm |
---|
377 | make world |
---|
378 | endif |
---|
379 | |
---|
380 | # install FK |
---|
381 | echo "extract FK package" |
---|
382 | cd $SH_UTIL |
---|
383 | if (-e fk_src) \rm -rf fk_src |
---|
384 | cp $pack_fk . |
---|
385 | set pack_fk=$pack_fk:t |
---|
386 | gzip -d $pack_fk |
---|
387 | set pack_fk=$pack_fk:r |
---|
388 | chmod +w $pack_fk |
---|
389 | tar xf $pack_fk |
---|
390 | \rm $pack_fk |
---|
391 | if (-e fk) \rm fk |
---|
392 | ln -s fk_src/fk fk |
---|
393 | |
---|
394 | # compile FK |
---|
395 | if ("$compile_fk" == "yes") then |
---|
396 | echo "compile FK package" |
---|
397 | cd fk_src |
---|
398 | \rm *.o |
---|
399 | make |
---|
400 | endif |
---|
401 | |
---|
402 | # install LocSAT |
---|
403 | echo "extract LocSAT package" |
---|
404 | cd $SH_UTIL |
---|
405 | if (-e locsat) \rm -rf locsat |
---|
406 | mkdir locsat |
---|
407 | cp $pack_locsat . |
---|
408 | set pack_locsat=$pack_locsat:t |
---|
409 | gzip -d $pack_locsat |
---|
410 | set pack_locsat=$pack_locsat:r |
---|
411 | chmod +w $pack_locsat |
---|
412 | tar xf $pack_locsat |
---|
413 | \rm $pack_locsat |
---|
414 | if (-e LocSAT) \rm LocSAT |
---|
415 | ln -s locsat/bin/LocSAT LocSAT |
---|
416 | |
---|
417 | # compile LocSAT |
---|
418 | if ("$compile_locsat" == "yes") then |
---|
419 | echo "compile LocSAT package" |
---|
420 | cd locsat |
---|
421 | set olist=`find . -name \*.o -print` |
---|
422 | \rm $olist |
---|
423 | set olist=`find . -name \*.a -print` |
---|
424 | \rm $olist |
---|
425 | cd $SH_UTIL/locsat/libsrc |
---|
426 | make |
---|
427 | cd $SH_UTIL/locsat/bin/LocSAT |
---|
428 | make |
---|
429 | endif |
---|
430 | |
---|
431 | # add SHM resources to .Xdefaults |
---|
432 | set resrc="" |
---|
433 | if (-e ~/.Xdefaults) set resrc=~/.Xdefaults |
---|
434 | if ("$resrc" == "") then |
---|
435 | if (-e ~/.Xresources) set resrc=~/.Xresources |
---|
436 | endif |
---|
437 | if ("$resrc" == "") then |
---|
438 | set resrc="~/.Xdefaults" |
---|
439 | touch $resrc |
---|
440 | endif |
---|
441 | set res=`grep "SHM*locsat_prefix_text" $resrc` |
---|
442 | if ("$res" == "") then |
---|
443 | echo "SHM*locsat_prefix_text.value: tab" >>$resrc |
---|
444 | echo "SHM*fk_frqlo_text.value: 0.4" >>$resrc |
---|
445 | echo "SHM*fk_frqhi_text.value: 3.0" >>$resrc |
---|
446 | echo "SHM*fk_slowness_text.value: 15" >>$resrc |
---|
447 | echo "SHM*fk_resol_text.value: 51" >>$resrc |
---|
448 | echo "SHM*fk_colnum_text.value: 10" >>$resrc |
---|
449 | echo "SHM*filter_butpar_hi_text.value: 1Hz" >>$resrc |
---|
450 | echo "SHM*filter_butpar_lo_text.value: 100s" >>$resrc |
---|
451 | echo "SHM*filter_butpar_order_text.value: 4" >>$resrc |
---|
452 | echo "SHM*opick_thresh_text.value: 10.0" >>$resrc |
---|
453 | echo "SHM*opick_duration_text.value: 1.0" >>$resrc |
---|
454 | echo "SHM*opick_break_text.value: 0.00" >>$resrc |
---|
455 | endif |
---|
456 | xrdb $resrc |
---|
457 | |
---|
458 | |
---|
459 | echo "" |
---|
460 | echo "" |
---|
461 | echo "Please call" |
---|
462 | echo "" |
---|
463 | echo "source $dstpath/sh/setup/shsetup" |
---|
464 | echo "" |
---|
465 | echo "before using SH or SHM. Put this line into your .cshrc file" |
---|
466 | echo "" |
---|