source: tags/arb_5.0/arb_install.sh

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