1 | #!/bin/bash |
---|
2 | |
---|
3 | # error message function (nested exit): |
---|
4 | trap "exit 1" TERM |
---|
5 | export ARBINST_SCRIPT_PID=$$ |
---|
6 | err() { |
---|
7 | echo "Error in `basename $0`:" 1>&2 |
---|
8 | echo " $@" 1>&2 |
---|
9 | echo "Please fix and then rerun script!" 1>&2 |
---|
10 | kill -s TERM $ARBINST_SCRIPT_PID |
---|
11 | } |
---|
12 | |
---|
13 | separator() { |
---|
14 | echo '' |
---|
15 | echo '*******************************************' |
---|
16 | } |
---|
17 | |
---|
18 | separator |
---|
19 | echo 'Welcome to the ARB Package' |
---|
20 | |
---|
21 | test -z "${BASH_VERSINFO}" && separator && err "Please call this script using 'bash arb_install.sh'" |
---|
22 | |
---|
23 | elim_invalid_chars() { |
---|
24 | local FILE="${1}" |
---|
25 | # remove some characters really unwanted in paths: |
---|
26 | FILE=${FILE// /} |
---|
27 | FILE=${FILE//\'/} |
---|
28 | FILE=${FILE//\"/} |
---|
29 | FILE=${FILE//\`/} |
---|
30 | echo ${FILE} |
---|
31 | } |
---|
32 | |
---|
33 | DL_DIR=$(pwd) |
---|
34 | DL_NS=$(elim_invalid_chars "${DL_DIR}") |
---|
35 | |
---|
36 | if [ ! "$DL_NS" = "$DL_DIR" ]; then |
---|
37 | separator |
---|
38 | if [ ! "$DL_NS" = "" ]; then |
---|
39 | echo "Note: the path '$DL_NS' would be ok.." |
---|
40 | fi |
---|
41 | err "Your download directory '$DL_DIR' contains invalid characters." |
---|
42 | fi |
---|
43 | |
---|
44 | cont() { |
---|
45 | echo "Warning: $@" 1>&2 |
---|
46 | echo 'Do you want to continue [y]' |
---|
47 | read var |
---|
48 | case "$var" in |
---|
49 | n) err "Script aborted by user" ;; |
---|
50 | *) echo 'Continuing...' ;; |
---|
51 | esac |
---|
52 | } |
---|
53 | |
---|
54 | untar() { |
---|
55 | # remove old DEPOT BUG |
---|
56 | rm -f DEPOT/gde/bin |
---|
57 | |
---|
58 | if [ ! -r $cwd/$1 ]; then |
---|
59 | err "Cannot find or read file $cwd/$1" |
---|
60 | fi |
---|
61 | if gunzip --stdout $cwd/$1 | tar xfv -; then |
---|
62 | echo ">>> $1 uncompressed and untared" |
---|
63 | if [ ! -e bin/arb_ntree ]; then |
---|
64 | err "bin/arb_ntree not found" |
---|
65 | fi |
---|
66 | if [ ! -x bin/arb_ntree ]; then |
---|
67 | err "bin/arb_ntree not executable" |
---|
68 | fi |
---|
69 | else |
---|
70 | err "Error in uncompressing or untaring $1" |
---|
71 | fi |
---|
72 | } |
---|
73 | |
---|
74 | separator |
---|
75 | echo ' Note: - You may abort this script with ctrl-"C"' |
---|
76 | echo ' - You can rerun this script as often as you like' |
---|
77 | echo ' - Old ARB data will be kept if requested (in this case' |
---|
78 | echo ' you can simply change some options)' |
---|
79 | echo ' - Pressing <return> will select the value in brackets' |
---|
80 | separator |
---|
81 | echo 'Please answer some questions:' |
---|
82 | separator |
---|
83 | echo 'Where would you like to install ARB?' |
---|
84 | echo ' ARB is not a single program but a set of programs, datafiles ...' |
---|
85 | echo ' To install ARB, all files will be stored in a single directory.' |
---|
86 | echo '' |
---|
87 | echo ' This script will create that directory, copy all needed files and' |
---|
88 | echo ' sets permissions correctly.' |
---|
89 | echo '' |
---|
90 | echo ' Please note that you will need write permission at the destination.' |
---|
91 | echo '' |
---|
92 | if [ "$EUID" -ne 0 ]; then |
---|
93 | # normal user |
---|
94 | ARBHOMED=${HOME}/arb |
---|
95 | echo ' - to install ARB inside your home directory, enter "'${ARBHOMED}'"' |
---|
96 | echo ' - otherwise press Ctrl-C now to abort installation and' |
---|
97 | echo ' rerun this script using:' |
---|
98 | echo ' sudo bash arb_install.sh' |
---|
99 | else |
---|
100 | # root user |
---|
101 | ARBHOMED=/usr/arb |
---|
102 | echo ' - to install ARB for all users, enter "'${ARBHOMED}'"' |
---|
103 | fi |
---|
104 | echo '' |
---|
105 | |
---|
106 | if [ "$ARBHOME" != "" ]; then |
---|
107 | if test -f $ARBHOME/lib/arb_tcp.dat; then |
---|
108 | echo " Note: There seems to be an existing arb installation at" |
---|
109 | echo " ${ARBHOME}" |
---|
110 | echo '' |
---|
111 | fi |
---|
112 | fi |
---|
113 | |
---|
114 | echo "Enter full installation path: [${ARBHOME:-${ARBHOMED}}]" |
---|
115 | read ARBHOMEI |
---|
116 | echo |
---|
117 | echo |
---|
118 | |
---|
119 | if [ "$ARBHOMEI" = "" ]; then |
---|
120 | ARBHOME="${ARBHOME:-${ARBHOMED}}"; |
---|
121 | else |
---|
122 | ARBHOME="${ARBHOMEI}"; |
---|
123 | fi |
---|
124 | |
---|
125 | # check for some really unwanted characters in path: |
---|
126 | AH_NS=$(elim_invalid_chars ${ARBHOME}) |
---|
127 | if [ ! "$AH_NS" = "$ARBHOME" ]; then |
---|
128 | separator |
---|
129 | if [ ! "$AH_NS" = "" ]; then |
---|
130 | echo "Note: the path '$AH_NS' would be ok.." |
---|
131 | fi |
---|
132 | err "The specified path '$ARBHOME' contains invalid characters." |
---|
133 | fi |
---|
134 | |
---|
135 | cwd=`pwd` |
---|
136 | |
---|
137 | if [ ! -f arb.tgz ]; then |
---|
138 | if [ -e arb-*.tgz ]; then |
---|
139 | # link any arb-*.tgz to arb.tgz |
---|
140 | ln -s arb-*.tgz arb.tgz |
---|
141 | ls -al arb.tgz arb-*.tgz |
---|
142 | if [ ! -L arb.tgz ]; then |
---|
143 | err "Failed to link any arb-tarball to arb.tgz (maybe there are multiple arb-*.tgz in this directory)" |
---|
144 | fi |
---|
145 | else |
---|
146 | err "Expected exactly one arb-*.tgz in current directory." |
---|
147 | fi |
---|
148 | else |
---|
149 | ls -al arb.tgz arb-*.tgz |
---|
150 | fi |
---|
151 | |
---|
152 | if [ ! -f arb.tgz ]; then |
---|
153 | if [ -L arb.tgz ]; then |
---|
154 | rm arb.tgz |
---|
155 | err "arb.tgz does not link to a file - removed link" |
---|
156 | else |
---|
157 | err "arb.tgz is neither file nor link - can't handle" |
---|
158 | fi |
---|
159 | fi |
---|
160 | |
---|
161 | if test -d $ARBHOME; then |
---|
162 | echo 'Creating backup copy of arb_tcp.dat ..' |
---|
163 | cp $ARBHOME/lib/arb_tcp.dat arb_tcp_`date +%Y%m%d`.dat |
---|
164 | |
---|
165 | if test -w $ARBHOME; then |
---|
166 | separator |
---|
167 | echo 'The destination directory' |
---|
168 | echo " $ARBHOME" |
---|
169 | echo 'already exists!' |
---|
170 | if [ -z "$(ls -A ${ARBHOME})" ]; then |
---|
171 | echo "Note: directory is empty and will be used for arb installation." |
---|
172 | else |
---|
173 | echo ' You may now' |
---|
174 | echo ' * either delete the old arb directory completely' |
---|
175 | echo ' * or only update/change options of the old version.' |
---|
176 | echo 'Delete old directory (y/n)[n]?' |
---|
177 | read delete_dir |
---|
178 | echo |
---|
179 | case "$delete_dir" in |
---|
180 | y) |
---|
181 | if rm -r $ARBHOME/* ;then |
---|
182 | echo ">>> all data in $ARBHOME deleted" |
---|
183 | else |
---|
184 | cont "failed to delete files in $ARBHOME" |
---|
185 | fi |
---|
186 | ;; |
---|
187 | *) |
---|
188 | if test -f $ARBHOME/lib/arb_tcp.dat; then |
---|
189 | bckup=$ARBHOME/lib/arb_tcp.dat.`date +%y%m%d%H%M%S` |
---|
190 | echo ">>>old $ARBHOME/lib/arb_tcp.dat found" |
---|
191 | echo ">>>backup to $bckup" |
---|
192 | cp $ARBHOME/lib/arb_tcp.dat $bckup |
---|
193 | fi |
---|
194 | echo ">>> old data not deleted";; |
---|
195 | esac |
---|
196 | fi |
---|
197 | else |
---|
198 | err "directory exists and is not writable"; |
---|
199 | fi |
---|
200 | else |
---|
201 | if mkdir -p $ARBHOME; then |
---|
202 | echo ">>> $ARBHOME created" |
---|
203 | else |
---|
204 | err "cannot create directory $ARBHOME"; |
---|
205 | fi |
---|
206 | fi |
---|
207 | |
---|
208 | cd $ARBHOME |
---|
209 | ARBHOME=`pwd` |
---|
210 | |
---|
211 | if test -d lib/pictures; then |
---|
212 | separator |
---|
213 | echo "Old ARB package found (type n to change only some options)." |
---|
214 | echo " Do you want to update the old package: (y/n)[y]" |
---|
215 | read var; |
---|
216 | case "$var" in |
---|
217 | n) |
---|
218 | echo "Old version unchanged";; |
---|
219 | *) |
---|
220 | echo "updating ARB"; |
---|
221 | untar arb.tgz;; |
---|
222 | esac |
---|
223 | else |
---|
224 | untar arb.tgz; |
---|
225 | fi |
---|
226 | |
---|
227 | separator |
---|
228 | echo 'Specify PT_SERVER files location' |
---|
229 | echo ' ARB needs a writeable directory to store the pt_server files. ' |
---|
230 | echo ' Those files are needed for fast database search' |
---|
231 | echo ' (by probe_design, probe_match and the automatic aligner)' |
---|
232 | echo ' and need a lot of disc space (up to several 100 mega bytes,' |
---|
233 | echo ' e.g. 4000 16S RNA sequences require about 40 MB).' |
---|
234 | echo ' This files are not created now. They can be build by any user via' |
---|
235 | echo ' <ARB_NTREE/Probes/PT_SERVER admin/Build server>' |
---|
236 | echo ' You may define a special directory as the pt_server files location.' |
---|
237 | echo ' This prevents any loss of data installing a new version of ' |
---|
238 | echo ' ARB. ' |
---|
239 | |
---|
240 | echo 'Where do you want to put your pt_server data' |
---|
241 | echo ' 1. <CR> - (new installation of ARB)' |
---|
242 | echo ' for placing pt_server data within ARB directory tree' |
---|
243 | echo ' (Default location).' |
---|
244 | echo ' - (updating ARB)' |
---|
245 | echo ' using the previous location' |
---|
246 | echo ' 2. "Path" to link pt_server data directory to' |
---|
247 | echo " (if you choose this option you won't loose your PT-Servers when doing future software updates)" |
---|
248 | echo 'Enter path:' |
---|
249 | read pt_dir |
---|
250 | echo |
---|
251 | case "$pt_dir" in |
---|
252 | "") |
---|
253 | echo "installing the pt_server data in $ARBHOME/lib/pts" |
---|
254 | if test -h ${ARBHOME}/lib/pts ; then |
---|
255 | echo "Are you sure to delete " |
---|
256 | echo ">>> pt_server files at non default location:" |
---|
257 | ls -ld ${ARBHOME}/lib/pts |
---|
258 | else |
---|
259 | if test -d ${ARBHOME}/lib/pts; then |
---|
260 | echo ">>> pt_server files at default location: unchanged" |
---|
261 | else |
---|
262 | (cd lib;rm -f pts;mkdir pts;) |
---|
263 | fi |
---|
264 | fi;; |
---|
265 | *) |
---|
266 | echo "changing your pt_server file location" |
---|
267 | if test -h ${ARBHOME}/lib/pts; then |
---|
268 | echo ">>> non default location found: removing old link" |
---|
269 | rm lib/pts |
---|
270 | else |
---|
271 | if test -d ${ARBHOME}/lib/pts; then |
---|
272 | echo ">>> data in default location found" |
---|
273 | echo 'Do you want to remove old ptserver data (recommended)? [y]' |
---|
274 | read ANSWER |
---|
275 | case "$ANSWER" in |
---|
276 | n) echo 'data not deleted' ;; |
---|
277 | *) rm -r lib/pts |
---|
278 | echo 'data deleted' ;; |
---|
279 | esac |
---|
280 | fi |
---|
281 | fi |
---|
282 | if test ! -d $pt_dir; then |
---|
283 | echo ">>> Creating special PT_SERVER directory $pt_dir" |
---|
284 | if mkdir -p $pt_dir; then |
---|
285 | echo ">>> $pt_dir created" |
---|
286 | else |
---|
287 | err "Couldn't create $pt_dir" |
---|
288 | fi |
---|
289 | fi |
---|
290 | (cd lib;ln -s $pt_dir pts;) |
---|
291 | esac |
---|
292 | |
---|
293 | separator |
---|
294 | echo 'Who is responsible for the PT_SERVER index files ?' |
---|
295 | echo ' Answer y: if you trust your users (less administration; recommended)' |
---|
296 | echo ' n: if PT_SERVER files shall only be changable by administrator' |
---|
297 | echo ' or simply press return to keep the settings of an old installation.' |
---|
298 | echo 'Should everybody be allowed to build/update PT_SERVER files (y/n/dont_change)[dont_change]?' |
---|
299 | read var |
---|
300 | echo |
---|
301 | case "$var" in |
---|
302 | y) |
---|
303 | echo ">>> all users are allowed to update the PT_SERVER"; |
---|
304 | chmod 777 lib/pts |
---|
305 | chmod 666 lib/pts/* 2>/dev/null ;; |
---|
306 | n) |
---|
307 | echo ">>> only `whoami` is allowed to update the pt_server"; |
---|
308 | chmod 755 lib/pts |
---|
309 | chmod 644 lib/pts/* 2>/dev/null ;; |
---|
310 | *) |
---|
311 | echo ">>> flags unchanged";; |
---|
312 | esac |
---|
313 | |
---|
314 | separator |
---|
315 | echo 'NameServer installation' |
---|
316 | echo ' The NameServer is a program, that synchronizes all species names' |
---|
317 | echo ' of the databases of different users.' |
---|
318 | echo ' Users that import foreign data into their database and want to' |
---|
319 | echo ' export those data to other ARB users should be allowed to change' |
---|
320 | echo ' the names file in $ARBHOME/lib/nas/names.dat' |
---|
321 | echo ' Answer y: if all users may import foreign databases' |
---|
322 | echo ' n: if there are some mean untrusty users' |
---|
323 | echo ' or simply press return to keep the old settings' |
---|
324 | echo 'Do you trust your users (y/n/dont_change)[dont_change]?' |
---|
325 | read var |
---|
326 | echo |
---|
327 | case "$var" in |
---|
328 | y) |
---|
329 | echo ">>> all user are allowed to change the names file"; |
---|
330 | chmod 777 lib/nas |
---|
331 | chmod 666 lib/nas/*;; |
---|
332 | n) |
---|
333 | echo ">>> only `whoami` is allowed to change the names file ${ARBHOME}/lib/nas/names.dat" |
---|
334 | chmod 755 lib/nas |
---|
335 | chmod 644 lib/nas/*;; |
---|
336 | *) |
---|
337 | echo ">>> flags unchanged";; |
---|
338 | esac |
---|
339 | |
---|
340 | separator |
---|
341 | echo 'Networking' |
---|
342 | echo ' To speed up calculation one special host can be assigned as' |
---|
343 | echo ' the PT_SERVER host. That means that all database search is done' |
---|
344 | echo ' on that host. This saves computer resources as different users' |
---|
345 | echo ' may share one server.' |
---|
346 | echo ' To get the best results this host "H" should:' |
---|
347 | echo ' 1. be fast,' |
---|
348 | echo ' 2. have a lot of real memory (>=64 meg),' |
---|
349 | echo ' 3. have a lot of swap space (>=400 meg),' |
---|
350 | echo ' 4. allow all users to run "ssh H ...",' |
---|
351 | echo ' 5. contain the discs with the PT_SERVER files.' |
---|
352 | |
---|
353 | echo ' n You want to assign a special Network host' |
---|
354 | echo ' s You have a Stand alone computer' |
---|
355 | if test "X$bckup" != "X"; then |
---|
356 | echo ' o Use information of already installed ARB' |
---|
357 | echo 'Choose (s/n/o)[s]?' |
---|
358 | else |
---|
359 | echo 'Choose (s/n)[s]?' |
---|
360 | |
---|
361 | fi |
---|
362 | read var |
---|
363 | echo |
---|
364 | |
---|
365 | |
---|
366 | |
---|
367 | case "$var" in |
---|
368 | o) |
---|
369 | mv $bckup lib/arb_tcp.dat; |
---|
370 | echo ">>> old lib/arb_tcp.dat restored";; |
---|
371 | n) |
---|
372 | separator |
---|
373 | echo "Enter the name of your host for the pt_server" |
---|
374 | read host |
---|
375 | echo "Checking connection to $host" |
---|
376 | if ssh $host ls >/dev/zero; then |
---|
377 | echo ">>> ssh $host ok" |
---|
378 | else |
---|
379 | err ">>> cannot run 'ssh $host'"; |
---|
380 | fi |
---|
381 | rm -f lib/arb_tcp.dat; |
---|
382 | cat lib/arb_tcp_org.dat |sed -e "/localhost\:/$host\:/g" >lib/arb_tcp.dat |
---|
383 | echo ">>> server installed";; |
---|
384 | *) |
---|
385 | cp lib/arb_tcp_org.dat lib/arb_tcp.dat |
---|
386 | echo ">>> server installed";; |
---|
387 | esac |
---|
388 | |
---|
389 | separator |
---|
390 | echo ">>> Installation Complete" |
---|
391 | |
---|
392 | separator |
---|
393 | SHELL_ANS=0 |
---|
394 | |
---|
395 | while [ "$SHELL_ANS" = "0" ]; do |
---|
396 | |
---|
397 | echo "Finally, you have to tell your system where to find arb." |
---|
398 | echo "First find out which shell you are using, by opening a new terminal window and typing" |
---|
399 | echo ' echo $SHELL' |
---|
400 | echo "" |
---|
401 | echo "Depending on what is your shell there are three choices:" |
---|
402 | echo "" |
---|
403 | echo " 1. Change your local .profile or .bashrc (if you are using ksh/bash, which" |
---|
404 | echo " is the default shell for Linux)" |
---|
405 | echo " 2. Change your local .cshrc file (if you are using csh/tcsh)" |
---|
406 | echo " 3. Create an alias for arb (any shell)" |
---|
407 | echo "" |
---|
408 | |
---|
409 | echo "Enter (1,2 or 3) to achieve further installation instructions:" |
---|
410 | |
---|
411 | read var |
---|
412 | |
---|
413 | echo ''; |
---|
414 | echo '**********************************************************************************************'; |
---|
415 | echo 'Follow the steps below with care!!!'; |
---|
416 | echo ''; |
---|
417 | case "$var" in |
---|
418 | 1) |
---|
419 | echo '******************************************************'; |
---|
420 | echo "add the following lines to your ~/.profile"; |
---|
421 | echo "or to your ~/.bashrc for bash-users"; |
---|
422 | echo '******************************************************'; |
---|
423 | echo " ARBHOME=$ARBHOME;export ARBHOME"; |
---|
424 | echo ' LD_LIBRARY_PATH=${ARBHOME}/lib:${LD_LIBRARY_PATH}'; |
---|
425 | echo ' export LD_LIBRARY_PATH'; |
---|
426 | echo ' PATH=${ARBHOME}/bin:${PATH}'; |
---|
427 | echo ' export PATH'; |
---|
428 | echo ' ' |
---|
429 | echo 'enter the following command:'; |
---|
430 | echo ' . ~/.profile' |
---|
431 | SHELL_ANS=1 ;; |
---|
432 | 2) |
---|
433 | echo '******************************************'; |
---|
434 | echo "add the following lines to your ~/.cshrc"; |
---|
435 | echo '******************************************'; |
---|
436 | echo " setenv ARBHOME $ARBHOME"; |
---|
437 | if test "X${LD_LIBRARY_PATH}" != "X"; then |
---|
438 | echo ' setenv LD_LIBRARY_PATH $ARBHOME/lib\:$LD_LIBRARY_PATH'; |
---|
439 | else |
---|
440 | echo ' setenv LD_LIBRARY_PATH $ARBHOME/lib'; |
---|
441 | fi |
---|
442 | echo ' setenv PATH $ARBHOME/bin\:$PATH'; |
---|
443 | echo ' ' |
---|
444 | echo 'enter the following command:'; |
---|
445 | echo ' source ~/.cshrc' |
---|
446 | SHELL_ANS=1 ;; |
---|
447 | 3) |
---|
448 | echo '**************************************************'; |
---|
449 | echo "add one of the following lines to your init file"; |
---|
450 | echo '**************************************************'; |
---|
451 | echo "# bash users add to ~/.bashrc:"; |
---|
452 | echo " alias arb=$ARBHOME/bin/arb"; |
---|
453 | echo "# tcsh users add to ~/.cshrc:"; |
---|
454 | echo " alias arb '$ARBHOME/bin/arb'"; |
---|
455 | SHELL_ANS=1 ;; |
---|
456 | *) |
---|
457 | echo 'Wrong answer';; |
---|
458 | esac |
---|
459 | done |
---|
460 | |
---|
461 | if [ "$EUID" -eq 0 ]; then |
---|
462 | # only shown to root user: |
---|
463 | echo "" |
---|
464 | echo "Note for sysadmins:" |
---|
465 | echo " In order to provide arb for all users, edit one or several" |
---|
466 | echo " of the global shell init files in /etc (e.g. /etc/bash.bashrc)" |
---|
467 | echo " in the same manner as described above for the" |
---|
468 | echo " local shell init files." |
---|
469 | echo "" |
---|
470 | echo " Note for unintended sysadmins:" |
---|
471 | echo " To edit the global bash init file use e.g." |
---|
472 | echo " sudo nano /etc/bash.bashrc" |
---|
473 | echo " Insert the 'arb' alias on a separate line." |
---|
474 | fi |
---|
475 | echo "" |
---|
476 | echo "Please read the files" |
---|
477 | echo " $ARBHOME/arb_INSTALL.txt" |
---|
478 | echo " $ARBHOME/arb_UBUNTU.txt (if you're using ubuntu)" |
---|
479 | echo "about additional libraries and tools needed by ARB." |
---|
480 | echo "" |
---|
481 | echo "After you have installed everything and performed the changes to your init file," |
---|
482 | echo "open a new terminal window and start arb by typing" |
---|
483 | echo "" |
---|
484 | echo " arb" |
---|
485 | echo "" |
---|
486 | echo "Have much fun using ARB" |
---|
487 | echo "ARB Team <arb@arb-home.de>" |
---|
488 | echo "" |
---|
489 | |
---|