root/tags/release_2007_12/arb_install.sh

Revision 4967, 12.7 KB (checked in by westram, 4 years ago)

- dummy change to force update

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