source: tags/arb-6.0/arb_install.sh

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