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