source: tags/cvs_2_svn/arb_install.sh

Last change on this file was 5398, checked in by westram, 16 years ago
  • fixed "408: ==: unexpected operator"
  • force bash by shebang
  • tweaked shell-init-file section
  • export arbhome to install_lib.sh
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 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 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 [ ! -x $cwd/zcat ]; then
28        if chmod 755 $cwd/zcat; then
29            echo ">>> chmod 755  $cwd/zcat succesfull"
30        else
31            err "Cannot chmod of $cwd/zcat"
32        fi
33    fi
34    if [ ! -r $cwd/$1 ]; then
35        err "Cannot find or read file  $cwd/$1"
36    fi
37    if $cwd/zcat $cwd/$1 |tar xfv -; then
38        echo ">>> $1 uncompressed and untared"
39    else
40        err "Error in uncompressing or untaring $1"
41    fi
42}
43
44seperator() {
45    echo ''
46    echo '*******************************************'
47}
48
49seperator
50echo 'Welcome to the ARB Package'
51seperator
52echo '  Note:   - You may abort this script with ctrl-"C"'
53echo '          - You can rerun this script as often as you like'
54echo '          - Old ARB data will be kept if requested (in this case'
55echo '            you can simply change some options)'
56echo '          - Pressing <return> will select the value in brackets'
57seperator
58echo 'Please answer some questions:'
59seperator
60echo 'Enter path where to install ARB ?'
61echo '  ARB is not a single programm but a set of programs, datafiles ...'
62echo '  To install ARB correctly all files are stored in a single '
63echo '  directory. This script creates such a directory and copies all'
64echo '  data into it, sets the correct permissions and optionally installs'
65echo '  some X11 stuff. Please enter the path of the directory where you want'
66echo '  to install ARB.'
67echo '  Notes:  This script optionally creates the destination directory.'
68echo '          You should have write permission at the destination location.'
69echo '                  - To install ARB in your home directory: Enter "arb"'
70echo '                  - Otherwise become root and rerun script.'
71echo '                  - On Linux computers this script should be run under root'
72echo ''
73echo '  Example: If there is enough space (~50 MB) at your /usr partition and'
74echo '  you want to install arb at /usr/arb, enter "/usr/arb"'
75
76if [ "$ARBHOME" != "" ]; then
77    if test -f $ARBHOME/lib/arb_tcp.dat; then
78        echo "  Note:   I found an old arb program at $ARBHOME"
79    fi
80fi
81
82echo "Enter full installation path: [${ARBHOME:-/usr/arb}]"
83read ARBHOMEI
84echo
85echo
86
87if [ "$ARBHOMEI" = "" ]; then
88    ARBHOME="${ARBHOME:-/usr/arb}";
89else
90    ARBHOME="${ARBHOMEI}";
91fi
92
93cwd=`pwd`
94if test -d $ARBHOME; then
95    echo 'Creating backup copy of arb_tcp.dat ..'
96    cp $ARBHOME/lib/arb_tcp.dat arb_tcp_`date +%Y%m%d`.dat
97
98    if test -w $ARBHOME; then
99        seperator
100        echo 'The destination directory'
101        echo "    $ARBHOME"
102        echo 'already exists!'
103        echo '  You can delete the old directory before installing ARB'
104        echo '  or only update/change options of the old version.'
105        echo 'Delete old directory (y/n)[n]?'
106        read delete_dir
107        echo
108        case "$delete_dir" in
109            y)
110            if rm -r $ARBHOME/* ;then
111                echo ">>> all data in $ARBHOME deleted"
112            else
113                cont "cannot delete all data in $ARBHOME"
114            fi;;
115            *)
116            if test -f $ARBHOME/lib/arb_tcp.dat; then
117                bckup=$ARBHOME/lib/arb_tcp.dat.`date +%y%m%d%H%M%S`
118                echo ">>>old $ARBHOME/lib/arb_tcp.dat found"
119                echo ">>>backup to $bckup"
120                cp $ARBHOME/lib/arb_tcp.dat $bckup
121            fi
122            echo ">>> old data not deleted";;
123        esac
124    else
125        err "directory exists and is not writable";
126    fi
127else
128    if mkdir -p $ARBHOME; then
129        echo ">>> $ARBHOME created"
130    else
131        err "cannot create directory $ARBHOME";
132    fi
133fi
134
135cd $ARBHOME
136ARBHOME=`pwd`
137
138if test -d lib/pictures; then
139    seperator
140    echo "Old ARB package found (type n to change only some options)."
141    echo "  Do you want to update the old package: (y/n)[y]"
142    read var;
143    case "$var" in
144        n)
145        echo "Old version unchanged";;
146        *)
147        echo "updating ARB";
148        untar arb.tgz;;
149    esac
150else
151    untar arb.tgz;
152fi
153
154if test -f $cwd/arb_ale.tgz; then
155    if test -f DEPOT2/emacs; then
156        seperator
157        echo "Old ARB_ALE package found"
158        echo "ARB_ALE is a sophisticated alignment editor written by RDP"
159        echo "  Do you want to update the old package: (y/n)[y]"
160        read var;
161        case "$var" in
162            n)
163            echo "Old ARB_ALE version unchanged";;
164            *)
165            echo "updating ARB_ALE"
166            untar arb_ale.tgz;;
167        esac
168    else
169        untar arb_ale.tgz;
170    fi
171fi
172
173seperator
174echo 'Specify PT_SERVER files location'
175echo '  ARB needs a writeable directory to store the pt_server files. '
176echo '  Those files are needed for fast database search'
177echo '  (by probe_design, probe_match and the automatic aligner)'
178echo '  and need a lot of disc space (up to several 100 mega bytes,'
179echo '  e.g. 4000 16S RNA sequences require about 40 MB).'
180echo '  This files are not created now. They can be build by any user via'
181echo '          <ARB_NTREE/Probes/PT_SERVER admin/Build server>'
182echo '  You may define a special directory as the pt_server files location.'
183echo '  This prevents any loss of data installing a new version of '
184echo '  ARB. '
185
186echo 'Where do you want to put your pt_server data'
187echo '          1. <CR> - (new installation of ARB)'
188echo '                    for placing pt_server data within ARB directory tree'
189echo '                    (Default location).'
190echo '                  - (updating ARB)'
191echo '                    using the previous location'
192echo '          2. "Path" to link pt_server data directory to'
193echo "              (if you choose this option you won't loose your PT-Servers when doing future software updates)"
194echo 'Enter path:'
195read pt_dir
196echo
197case "$pt_dir" in
198    "")
199    echo "installing the pt_server data in $ARBHOME/lib/pts"
200    if test -h ${ARBHOME}/lib/pts ; then
201        echo "Are you sure to delete "
202        echo ">>> pt_server files at non default location:"
203        ls -ld ${ARBHOME}/lib/pts
204    else
205        if test -d ${ARBHOME}/lib/pts; then
206            echo ">>> pt_server files at default location: unchanged"
207        else
208            (cd lib;rm -f pts;mkdir pts;)
209        fi
210    fi;;
211    *)
212    echo "changing your pt_server file location"
213    if test -h ${ARBHOME}/lib/pts; then
214        echo ">>> non default location found: removing old link"
215        rm lib/pts
216    else
217        if test -d ${ARBHOME}/lib/pts; then
218            echo ">>> data in default location found"
219            echo 'Do you want to remove old ptserver data (recommended)? [y]'
220            read ANSWER
221            case "$ANSWER" in
222                n) echo 'data not deleted' ;;
223                *) rm -r lib/pts
224                echo 'data deleted' ;;
225            esac
226        fi
227    fi
228    if test ! -d $pt_dir; then
229        echo ">>> Creating special PT_SERVER directory $pt_dir"
230        if mkdir -p $pt_dir; then
231            echo ">>> $pt_dir created"
232        else
233            err "Couldn't create $pt_dir"
234        fi
235    fi
236    (cd lib;ln -s $pt_dir pts;)
237esac
238
239seperator
240echo 'Who is responsible for the PT_SERVER index files ?'
241echo '  Answer  y: if you trust your users (less administration)'
242echo '          n: if YOU want to administrate all PT_SERVER files'
243echo '  or simply press return to keep the settings of an old installation.'
244echo 'Should everybody be allowed to build/update PT_SERVER files (y/n/dont_change)[dont_change]?'
245read var
246echo
247case "$var" in
248    y)
249    echo ">>> all users are allowed to update the PT_SERVER";
250    chmod 777 lib/pts
251    chmod 666 lib/pts/* 2>/dev/null ;;
252    n)
253    echo ">>> only `whoami` is allowed to update the pt_server";
254    chmod 755 lib/pts
255    chmod 644 lib/pts/* 2>/dev/null ;;
256    *)
257    echo ">>> flags unchanged";;
258esac
259
260seperator
261echo 'NameServer installation'
262echo '  The NameServer is a programm, that synchronizes all species names'
263echo '  of the databases of different users.'
264echo '  Users that import foreign data into their database and want to'
265echo '  export those data to other ARB users should be allowed to change'
266echo '  the names file in $ARBHOME/lib/nas/names.dat'
267echo '  Answer  y: if all users may import foreign databases'
268echo '          n: if there are some mean untrusty users'
269echo '  or simply press return to keep the old settings'
270echo 'Do you trust your users (y/n/dont_change)[dont_change]?'
271read var
272echo
273case "$var" in
274    y)
275    echo ">>> all user are allowed to change the names file";
276    chmod 777 lib/nas
277    chmod 666 lib/nas/*;;
278    n)
279    echo ">>> only `whoami` is allowed to change the names file ${ARBHOME}/lib/nas/names.dat"
280    chmod 755 lib/nas
281    chmod 644 lib/nas/*;;
282    *)
283    echo ">>> flags unchanged";;
284esac
285
286seperator
287echo 'Networking'
288echo '  To speed up calculation one special host can be assigned as'
289echo '  the PT_SERVER host. That means that all database search is done'
290echo '  on that host. This saves computer resources as different users'
291echo '  may share one server.'
292echo '  To get the best results this host "H" should:'
293echo '                  1.      be fast,'
294echo '                  2.      have a lot of real memory (>=64 meg),'
295echo '                  3.      have a lot of swap space (>=400 meg),'
296echo '                  4.      allow all users to run "ssh H ...",'
297echo '                  5.      contain the discs with the PT_SERVER files.'
298
299echo '  n       You want to assign a special Network host'
300echo '  s       You have a Stand alone computer'
301if test "X$bckup" != "X"; then
302    echo '        o       Use information of already installed ARB'
303    echo 'Choose (s/n/o)[s]?'
304else
305    echo 'Choose (s/n)[s]?'
306
307fi
308read var
309echo
310
311
312
313case "$var" in
314    o)
315    mv $bckup lib/arb_tcp.dat;
316    echo ">>> old lib/arb_tcp.dat restored";;
317    n)
318    seperator
319    echo "Enter the name of your host for the pt_server"
320    read host
321    echo "Checking connection to $host"
322    if ssh $host ls >/dev/zero; then
323        echo ">>> ssh $host ok"
324    else
325        err ">>> cannot run 'ssh $host'";
326    fi
327    rm -f lib/arb_tcp.dat;
328    cat lib/arb_tcp_org.dat |sed -e "/localhost\:/$host\:/g" >lib/arb_tcp.dat
329    echo ">>> server installed";;
330    *)
331    cp lib/arb_tcp_org.dat lib/arb_tcp.dat
332    echo ">>> server installed";;
333esac
334
335# install missing libraries
336seperator
337( export ARBHOME ; $ARBHOME/lib/addlibs/install_libs.sh )
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 shell 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 "When you performed these changes, open a new terminal window"
420echo "and start arb by typing"
421echo ""
422echo "     arb"
423echo ""
424echo "Have much fun using ARB"
425echo "ARB Team <arb@arb-home.de>"
426echo ""
427
428unset host
429unset cwd
430unset ARBHOME
431unset delete_dir
432unset keep_debug
433unset pt_dir
434unset var
Note: See TracBrowser for help on using the repository browser.