1 | #! /bin/csh |
---|
2 | # |
---|
3 | # file install.csh |
---|
4 | # =========== |
---|
5 | # |
---|
6 | # version 5, 17-Feb-2011 |
---|
7 | # |
---|
8 | # Installation script for SH/SHM package |
---|
9 | |
---|
10 | set ext="undefined" |
---|
11 | if ("`uname`" == "Linux") then |
---|
12 | set ext="linux" |
---|
13 | else if ("`uname`" == "SunOS") then |
---|
14 | set ext="sol2.5.1" |
---|
15 | endif |
---|
16 | |
---|
17 | if ("$1" == "") then |
---|
18 | echo "To be only used from self-extracting setup process!" |
---|
19 | else |
---|
20 | # get parameters |
---|
21 | set dstpath=$1 |
---|
22 | endif |
---|
23 | |
---|
24 | # check parameters |
---|
25 | if (! -w $dstpath) then |
---|
26 | echo "$0 : cannot write to installation path $dstpath. Abort." |
---|
27 | exit 1 |
---|
28 | endif |
---|
29 | |
---|
30 | # find input files |
---|
31 | set pack_fk="" |
---|
32 | set pack_locsat="" |
---|
33 | |
---|
34 | if ("`uname`" == "Linux") then |
---|
35 | if (-e $dstpath/fk-linux.tar.gz) set pack_fk=$dstpath/fk-linux.tar.gz |
---|
36 | if (-e $dstpath/locsat-linux.tar.gz) set pack_locsat=$dstpath/locsat-linux.tar.gz |
---|
37 | else if ("`uname`" == "SunOS") then |
---|
38 | if (-e $dstpath/fk-sol2.5.1.tar.gz) set pack_fk=$dstpath/fk-sol2.5.1.tar.gz |
---|
39 | if (-e $dstpath/locsat-sol2.5.1.tar.gz) set pack_locsat=$dstpath/locsat-sol2.5.1.tar.gz |
---|
40 | else |
---|
41 | endif |
---|
42 | |
---|
43 | if (-e $dstpath/libahio.a.$ext) then |
---|
44 | set use_ah=1 |
---|
45 | else |
---|
46 | set use_ah=0 |
---|
47 | endif |
---|
48 | |
---|
49 | |
---|
50 | # default values |
---|
51 | set displ_res="undef" |
---|
52 | set userroot='$HOME/shfiles' |
---|
53 | if ("`uname`" == "Linux") then |
---|
54 | set linux_colors="yes" |
---|
55 | else |
---|
56 | set linux_colors="no" |
---|
57 | endif |
---|
58 | |
---|
59 | # find text editor |
---|
60 | set editor="" |
---|
61 | foreach ed (kate kwrite gedit textedit vuepad leafpad mousepad nedit xedit) |
---|
62 | set res=`which $ed` |
---|
63 | if (-e "$res") then |
---|
64 | set editor=$ed |
---|
65 | break |
---|
66 | endif |
---|
67 | end |
---|
68 | |
---|
69 | # find ps viewer |
---|
70 | set psview="" |
---|
71 | foreach psv (kghostview kpdf okular evince ggv gv xpdf pageview acroread) |
---|
72 | set res=`which $psv` |
---|
73 | if (-e "$res") then |
---|
74 | set psview=$psv |
---|
75 | break |
---|
76 | endif |
---|
77 | end |
---|
78 | |
---|
79 | # check for some programs in search path |
---|
80 | set plist = ( gzip make gccmakedep gcc uil ar ranlib xterm ) |
---|
81 | foreach p ($plist) |
---|
82 | set res=`which $p` |
---|
83 | if (! -e "$res") then |
---|
84 | echo "Program $p not found in search path. Please add." |
---|
85 | exit 2 |
---|
86 | endif |
---|
87 | end |
---|
88 | |
---|
89 | set filterset="iaspei" |
---|
90 | |
---|
91 | # enter setup menu |
---|
92 | |
---|
93 | set cmd="" |
---|
94 | while ("$cmd" != "i") |
---|
95 | |
---|
96 | echo "======================================================================" |
---|
97 | echo "" |
---|
98 | echo "(u) user root path: $userroot" |
---|
99 | echo "(f) filter set: $filterset" |
---|
100 | echo "(e) window based texteditor: $editor" |
---|
101 | echo "(p) postscript viewer: $psview" |
---|
102 | echo "(c) linux colors: $linux_colors" |
---|
103 | echo "(i) Start Installation" |
---|
104 | echo "(q) Quit Installation" |
---|
105 | echo "" |
---|
106 | echo "If all settings are ok, enter 'i'" |
---|
107 | echo "" |
---|
108 | echo -n "Your command: " |
---|
109 | set cmd="$<" |
---|
110 | |
---|
111 | if ("$cmd" == "q") exit 99 |
---|
112 | if ("$cmd" == "r") then |
---|
113 | if ("$displ_res" == "xga") then |
---|
114 | set displ_res="wxga" |
---|
115 | else if ("$displ_res" == "wxga") then |
---|
116 | set displ_res="sxga" |
---|
117 | else |
---|
118 | set displ_res="xga" |
---|
119 | endif |
---|
120 | endif |
---|
121 | if ("$cmd" == "c") then |
---|
122 | if ("$linux_colors" == "yes") then |
---|
123 | set linux_colors="no" |
---|
124 | else |
---|
125 | set linux_colors="yes" |
---|
126 | endif |
---|
127 | endif |
---|
128 | if ("$cmd" == "e") then |
---|
129 | echo -n "window based texteditor: " |
---|
130 | set editor="$<" |
---|
131 | if (! -e $editor) then |
---|
132 | echo "$editor does not exist." |
---|
133 | echo -n "Enter <Return> ..." |
---|
134 | set x="$<" |
---|
135 | set editor="" |
---|
136 | endif |
---|
137 | endif |
---|
138 | if ("$cmd" == "p") then |
---|
139 | echo -n "postscript viewer: " |
---|
140 | set psview="$<" |
---|
141 | if (! -e $psview) then |
---|
142 | echo "$psview does not exist." |
---|
143 | echo -n "Enter <Return> ..." |
---|
144 | set x="$<" |
---|
145 | set psview="" |
---|
146 | endif |
---|
147 | endif |
---|
148 | if ("$cmd" == "u") then |
---|
149 | echo -n "user root path: " |
---|
150 | set userroot="$<" |
---|
151 | if (! -e $userroot) then |
---|
152 | mkdir $userroot |
---|
153 | if (! -e $userroot) then |
---|
154 | echo "cannot create $userroot. Reset to default." |
---|
155 | echo -n "Enter <Return> ..." |
---|
156 | set x="$<" |
---|
157 | set userroot=$HOME/shfiles |
---|
158 | endif |
---|
159 | endif |
---|
160 | endif |
---|
161 | if ("$cmd" == "f") then |
---|
162 | echo -n "filter set (classic or iaspei): " |
---|
163 | set filterset="$<" |
---|
164 | if ("$filterset" != "classic") then |
---|
165 | set filterset="iaspei" |
---|
166 | endif |
---|
167 | endif |
---|
168 | if ("$cmd" == "i") then |
---|
169 | if ("$editor" == "") then |
---|
170 | echo "Please specify window based texteditor executable." |
---|
171 | echo -n "Enter <Return> ..." |
---|
172 | set x="$<" |
---|
173 | set cmd="." |
---|
174 | endif |
---|
175 | if ("$psview" == "") then |
---|
176 | echo "Please specify postscript viewer executable." |
---|
177 | echo -n "Enter <Return> ..." |
---|
178 | set x="$<" |
---|
179 | set cmd="." |
---|
180 | endif |
---|
181 | endif |
---|
182 | end |
---|
183 | |
---|
184 | cd $dstpath |
---|
185 | |
---|
186 | # create setup file from template |
---|
187 | echo "prepare setup file" |
---|
188 | cd sh/setup |
---|
189 | if ("`uname`" == "Linux") then |
---|
190 | set remstr="#OS-linux " |
---|
191 | else if ("`uname`" == "SunOS") then |
---|
192 | set remstr="#OS-sol2 " |
---|
193 | else |
---|
194 | echo "$0 : sorry, this operating system is not supported" |
---|
195 | exit 3 |
---|
196 | endif |
---|
197 | set locsatpath=$dstpath/sh/util/locsat |
---|
198 | set plth=`echo $locsatpath | wc -c` |
---|
199 | |
---|
200 | # check for write access in /usr/bin -> create link for LocSAT installation path |
---|
201 | if (-w /usr/local) then |
---|
202 | if (-e /usr/local/LocSAT) \rm /usr/bin/LocSAT |
---|
203 | ln -s $locsatpath /usr/local/LocSAT |
---|
204 | set locsatpath=/usr/local/LocSAT |
---|
205 | # otherwise create link directly from user dir |
---|
206 | else if ($plth > 25) then |
---|
207 | if (-e $HOME/lcs) \rm $HOME/lcs |
---|
208 | ln -s $locsatpath $HOME/lcs |
---|
209 | set locsatpath=$HOME/lcs |
---|
210 | set plth=`echo $locsatpath | wc -c` |
---|
211 | if ($plth > 25) then |
---|
212 | echo "$0 : cannot find short locsat path. Abort." |
---|
213 | exit 4 |
---|
214 | endif |
---|
215 | endif |
---|
216 | |
---|
217 | sed "s/$remstr//" shsetup.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \ |
---|
218 | sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \ |
---|
219 | sed "s@##PSVIEW##@$psview@" | \ |
---|
220 | sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup |
---|
221 | sed "s/$remstr//" shsetup.sh.template | sed "s@##ROOTPATH##@$dstpath/sh@" | \ |
---|
222 | sed "s@##LOCSATPATH##@$locsatpath@" | sed "s@##EDITOR##@$editor@" | \ |
---|
223 | sed "s@##PSVIEW##@$psview@" | \ |
---|
224 | sed 's/-DSH_SETUP_SZGRF//' | sed "s@##USERROOT##@$userroot@" > shsetup.sh |
---|
225 | |
---|
226 | if ($use_ah == 0) then |
---|
227 | sed --in-place 's/-DSH_SETUP_AH//' shsetup |
---|
228 | sed --in-place 's/-lahio//' shsetup |
---|
229 | endif |
---|
230 | if ($?MACHTYPE == 1) then |
---|
231 | if ("`echo $MACHTYPE | grep 64`" != "") then |
---|
232 | if (-d /usr/X11R6/lib64) then |
---|
233 | sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup |
---|
234 | sed --in-place 's/\/usr\/X11R6\/lib/\/usr\/X11R6\/lib64/' shsetup.sh |
---|
235 | endif |
---|
236 | endif |
---|
237 | endif |
---|
238 | source shsetup |
---|
239 | |
---|
240 | # create directories for evt files |
---|
241 | if (! -e $SH_USERROOT/evt/evid ) mkdir -p $SH_USERROOT/evt/evid |
---|
242 | if (! -e $SH_USERROOT/evt/evtout ) mkdir -p $SH_USERROOT/evt/evtout |
---|
243 | |
---|
244 | # find screen resolution |
---|
245 | set displ_res=`$dstpath/sh/util/get_screen_resolution.csh` |
---|
246 | if ($#displ_res != 3) then |
---|
247 | echo "cannot find screen resolution, please set manually" |
---|
248 | set displ_res="sxga" |
---|
249 | else |
---|
250 | echo "found screen resolution $displ_res" |
---|
251 | set displ_res=$displ_res[3] |
---|
252 | endif |
---|
253 | |
---|
254 | set origsetup=$dstpath/sh/inputs/shm-config-default.txt |
---|
255 | if (! -e $origsetup) then |
---|
256 | echo "Installation program error. Sorry." |
---|
257 | exit 5 |
---|
258 | endif |
---|
259 | set thissetup=$dstpath/sh/inputs/shm-config.txt |
---|
260 | if (-e $thissetup) then |
---|
261 | \mv $thissetup $dstpath/sh/inputs/shm-config.txt.yours |
---|
262 | echo "A backup of your shm-config.txt has been saved under:" |
---|
263 | echo $dstpath/sh/inputs/shm-config.txt.yours |
---|
264 | endif |
---|
265 | sed "s@##EDITOR##@$editor@" $origsetup > $thissetup |
---|
266 | |
---|
267 | # settings for small displays (laptops) |
---|
268 | if ("$displ_res" != "" && "$displ_res" != "sxga") then |
---|
269 | sed --in-place "s/shm-cof-sxga-geometry/shm-conf-$displ_res-geometry/" $thissetup |
---|
270 | endif |
---|
271 | |
---|
272 | # linux colors |
---|
273 | if ("$linux_colors" == "yes") then |
---|
274 | # do nothing, this is default |
---|
275 | else |
---|
276 | sed --in-place 's/reverse_xors true/reverse_xors false/' $thissetup |
---|
277 | endif |
---|
278 | |
---|
279 | # filter set |
---|
280 | cp $SH_FILTER/$filterset/* $SH_FILTER |
---|
281 | |
---|
282 | echo "compiling SHM" |
---|
283 | cd $SH_ROOT |
---|
284 | # remove all o's and a's |
---|
285 | find . -name '*.o' -print0 | xargs -0 rm |
---|
286 | cd $SH_LIB |
---|
287 | if (-e libahio.a) mv libahio.a libahio.ax |
---|
288 | \rm *.a > /dev/null |
---|
289 | if (-e libahio.ax) mv libahio.ax libahio.a |
---|
290 | cd $SH_ROOT |
---|
291 | make depend_shm |
---|
292 | make shm |
---|
293 | make world |
---|
294 | |
---|
295 | # install FK |
---|
296 | echo "extract FK package" |
---|
297 | cd $SH_UTIL |
---|
298 | if (-e fk_src) \rm -rf fk_src |
---|
299 | cp $pack_fk . |
---|
300 | set pack_fk=$pack_fk:t |
---|
301 | gzip -d $pack_fk |
---|
302 | set pack_fk=$pack_fk:r |
---|
303 | chmod +w $pack_fk |
---|
304 | tar xf $pack_fk |
---|
305 | \rm $pack_fk |
---|
306 | if (-e fk) \rm fk |
---|
307 | ln -s fk_src/fk fk |
---|
308 | |
---|
309 | # install LocSAT |
---|
310 | echo "extract LocSAT package" |
---|
311 | cd $SH_UTIL |
---|
312 | if (-e locsat) \rm -rf locsat |
---|
313 | mkdir locsat |
---|
314 | cp $pack_locsat . |
---|
315 | set pack_locsat=$pack_locsat:t |
---|
316 | gzip -d $pack_locsat |
---|
317 | set pack_locsat=$pack_locsat:r |
---|
318 | chmod +w $pack_locsat |
---|
319 | tar xf $pack_locsat |
---|
320 | \rm $pack_locsat |
---|
321 | if (-e LocSAT) \rm LocSAT |
---|
322 | ln -s locsat/bin/LocSAT LocSAT |
---|
323 | |
---|
324 | # add SHM resources to .Xdefaults |
---|
325 | set resrc="" |
---|
326 | if (-e ~/.Xdefaults) set resrc=~/.Xdefaults |
---|
327 | if ("$resrc" == "") then |
---|
328 | if (-e ~/.Xresources) set resrc=~/.Xresources |
---|
329 | endif |
---|
330 | if ("$resrc" == "") then |
---|
331 | set resrc="~/.Xdefaults" |
---|
332 | touch $resrc |
---|
333 | endif |
---|
334 | set res=`grep "SHM.locsat_prefix_text" $resrc` |
---|
335 | if ("$res" == "") then |
---|
336 | echo "SHM*locsat_prefix_text.value: tab" >>$resrc |
---|
337 | echo "SHM*fk_frqlo_text.value: 0.4" >>$resrc |
---|
338 | echo "SHM*fk_frqhi_text.value: 3.0" >>$resrc |
---|
339 | echo "SHM*fk_slowness_text.value: 15" >>$resrc |
---|
340 | echo "SHM*fk_resol_text.value: 51" >>$resrc |
---|
341 | echo "SHM*fk_colnum_text.value: 10" >>$resrc |
---|
342 | echo "SHM*filter_butpar_hi_text.value: 1Hz" >>$resrc |
---|
343 | echo "SHM*filter_butpar_lo_text.value: 100s" >>$resrc |
---|
344 | echo "SHM*filter_butpar_order_text.value: 4" >>$resrc |
---|
345 | echo "SHM*opick_thresh_text.value: 10.0" >>$resrc |
---|
346 | echo "SHM*opick_duration_text.value: 1.0" >>$resrc |
---|
347 | echo "SHM*opick_break_text.value: 0.00" >>$resrc |
---|
348 | endif |
---|
349 | xrdb $resrc |
---|
350 | |
---|
351 | echo "========================================================================" |
---|
352 | echo "" |
---|
353 | echo "Please update your environment before using SH or SHM!" |
---|
354 | echo "" |
---|
355 | echo "If you prefer csh or tcsh put this line into your ~/.cshrc file:" |
---|
356 | echo "source $dstpath/sh/setup/shsetup" |
---|
357 | echo "" |
---|
358 | echo "If you prefer bash put this line into your ~/.bashrc file:" |
---|
359 | echo "source $dstpath/sh/setup/shsetup.sh" |
---|
360 | echo "" |
---|
361 | echo "========================================================================" |
---|