root/tags/arb_5.1/arb_install.sh

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