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