| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | # error message function |
|---|
| 4 | err() { |
|---|
| 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 | |
|---|
| 13 | cont() { |
|---|
| 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 | |
|---|
| 23 | untar() { |
|---|
| 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 | |
|---|
| 43 | separator() { |
|---|
| 44 | echo '' |
|---|
| 45 | echo '*******************************************' |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | separator |
|---|
| 49 | echo 'Welcome to the ARB Package' |
|---|
| 50 | separator |
|---|
| 51 | echo ' Note: - You may abort this script with ctrl-"C"' |
|---|
| 52 | echo ' - You can rerun this script as often as you like' |
|---|
| 53 | echo ' - Old ARB data will be kept if requested (in this case' |
|---|
| 54 | echo ' you can simply change some options)' |
|---|
| 55 | echo ' - Pressing <return> will select the value in brackets' |
|---|
| 56 | separator |
|---|
| 57 | echo 'Please answer some questions:' |
|---|
| 58 | separator |
|---|
| 59 | echo 'Enter path where to install ARB ?' |
|---|
| 60 | echo ' ARB is not a single program but a set of programs, datafiles ...' |
|---|
| 61 | echo ' To install ARB correctly all files are stored in a single ' |
|---|
| 62 | echo ' directory. This script creates such a directory and copies all' |
|---|
| 63 | echo ' data into it, sets the correct permissions and optionally installs' |
|---|
| 64 | echo ' some X11 stuff. Please enter the path of the directory where you want' |
|---|
| 65 | echo ' to install ARB.' |
|---|
| 66 | echo ' Notes: This script optionally creates the destination directory.' |
|---|
| 67 | echo ' You should have write permission at the destination location.' |
|---|
| 68 | echo ' - To install ARB in your home directory: Enter "'$HOME'/arb"' |
|---|
| 69 | echo ' - Otherwise become root and rerun script.' |
|---|
| 70 | echo ' - On Linux computers this script should be run under root' |
|---|
| 71 | echo '' |
|---|
| 72 | echo ' Example: If there is enough space (~50 MB) at your /usr partition and' |
|---|
| 73 | echo ' you want to install arb at /usr/arb, enter "/usr/arb"' |
|---|
| 74 | |
|---|
| 75 | if [ "$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 |
|---|
| 79 | fi |
|---|
| 80 | |
|---|
| 81 | echo "Enter full installation path: [${ARBHOME:-/usr/arb}]" |
|---|
| 82 | read ARBHOMEI |
|---|
| 83 | echo |
|---|
| 84 | echo |
|---|
| 85 | |
|---|
| 86 | if [ "$ARBHOMEI" = "" ]; then |
|---|
| 87 | ARBHOME="${ARBHOME:-/usr/arb}"; |
|---|
| 88 | else |
|---|
| 89 | ARBHOME="${ARBHOMEI}"; |
|---|
| 90 | fi |
|---|
| 91 | |
|---|
| 92 | cwd=`pwd` |
|---|
| 93 | |
|---|
| 94 | if [ ! -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 |
|---|
| 105 | else |
|---|
| 106 | ls -al arb.tgz arb-*.tgz |
|---|
| 107 | fi |
|---|
| 108 | |
|---|
| 109 | if [ ! -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 |
|---|
| 116 | fi |
|---|
| 117 | |
|---|
| 118 | if 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 |
|---|
| 151 | else |
|---|
| 152 | if mkdir -p $ARBHOME; then |
|---|
| 153 | echo ">>> $ARBHOME created" |
|---|
| 154 | else |
|---|
| 155 | err "cannot create directory $ARBHOME"; |
|---|
| 156 | fi |
|---|
| 157 | fi |
|---|
| 158 | |
|---|
| 159 | cd $ARBHOME |
|---|
| 160 | ARBHOME=`pwd` |
|---|
| 161 | |
|---|
| 162 | if 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 |
|---|
| 174 | else |
|---|
| 175 | untar arb.tgz; |
|---|
| 176 | fi |
|---|
| 177 | |
|---|
| 178 | separator |
|---|
| 179 | echo 'Specify PT_SERVER files location' |
|---|
| 180 | echo ' ARB needs a writeable directory to store the pt_server files. ' |
|---|
| 181 | echo ' Those files are needed for fast database search' |
|---|
| 182 | echo ' (by probe_design, probe_match and the automatic aligner)' |
|---|
| 183 | echo ' and need a lot of disc space (up to several 100 mega bytes,' |
|---|
| 184 | echo ' e.g. 4000 16S RNA sequences require about 40 MB).' |
|---|
| 185 | echo ' This files are not created now. They can be build by any user via' |
|---|
| 186 | echo ' <ARB_NTREE/Probes/PT_SERVER admin/Build server>' |
|---|
| 187 | echo ' You may define a special directory as the pt_server files location.' |
|---|
| 188 | echo ' This prevents any loss of data installing a new version of ' |
|---|
| 189 | echo ' ARB. ' |
|---|
| 190 | |
|---|
| 191 | echo 'Where do you want to put your pt_server data' |
|---|
| 192 | echo ' 1. <CR> - (new installation of ARB)' |
|---|
| 193 | echo ' for placing pt_server data within ARB directory tree' |
|---|
| 194 | echo ' (Default location).' |
|---|
| 195 | echo ' - (updating ARB)' |
|---|
| 196 | echo ' using the previous location' |
|---|
| 197 | echo ' 2. "Path" to link pt_server data directory to' |
|---|
| 198 | echo " (if you choose this option you won't loose your PT-Servers when doing future software updates)" |
|---|
| 199 | echo 'Enter path:' |
|---|
| 200 | read pt_dir |
|---|
| 201 | echo |
|---|
| 202 | case "$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;) |
|---|
| 242 | esac |
|---|
| 243 | |
|---|
| 244 | separator |
|---|
| 245 | echo 'Who is responsible for the PT_SERVER index files ?' |
|---|
| 246 | echo ' Answer y: if you trust your users (less administration; recommended)' |
|---|
| 247 | echo ' n: if PT_SERVER files shall only be changable by administrator' |
|---|
| 248 | echo ' or simply press return to keep the settings of an old installation.' |
|---|
| 249 | echo 'Should everybody be allowed to build/update PT_SERVER files (y/n/dont_change)[dont_change]?' |
|---|
| 250 | read var |
|---|
| 251 | echo |
|---|
| 252 | case "$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";; |
|---|
| 263 | esac |
|---|
| 264 | |
|---|
| 265 | separator |
|---|
| 266 | echo 'NameServer installation' |
|---|
| 267 | echo ' The NameServer is a program, that synchronizes all species names' |
|---|
| 268 | echo ' of the databases of different users.' |
|---|
| 269 | echo ' Users that import foreign data into their database and want to' |
|---|
| 270 | echo ' export those data to other ARB users should be allowed to change' |
|---|
| 271 | echo ' the names file in $ARBHOME/lib/nas/names.dat' |
|---|
| 272 | echo ' Answer y: if all users may import foreign databases' |
|---|
| 273 | echo ' n: if there are some mean untrusty users' |
|---|
| 274 | echo ' or simply press return to keep the old settings' |
|---|
| 275 | echo 'Do you trust your users (y/n/dont_change)[dont_change]?' |
|---|
| 276 | read var |
|---|
| 277 | echo |
|---|
| 278 | case "$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";; |
|---|
| 289 | esac |
|---|
| 290 | |
|---|
| 291 | separator |
|---|
| 292 | echo 'Networking' |
|---|
| 293 | echo ' To speed up calculation one special host can be assigned as' |
|---|
| 294 | echo ' the PT_SERVER host. That means that all database search is done' |
|---|
| 295 | echo ' on that host. This saves computer resources as different users' |
|---|
| 296 | echo ' may share one server.' |
|---|
| 297 | echo ' To get the best results this host "H" should:' |
|---|
| 298 | echo ' 1. be fast,' |
|---|
| 299 | echo ' 2. have a lot of real memory (>=64 meg),' |
|---|
| 300 | echo ' 3. have a lot of swap space (>=400 meg),' |
|---|
| 301 | echo ' 4. allow all users to run "ssh H ...",' |
|---|
| 302 | echo ' 5. contain the discs with the PT_SERVER files.' |
|---|
| 303 | |
|---|
| 304 | echo ' n You want to assign a special Network host' |
|---|
| 305 | echo ' s You have a Stand alone computer' |
|---|
| 306 | if test "X$bckup" != "X"; then |
|---|
| 307 | echo ' o Use information of already installed ARB' |
|---|
| 308 | echo 'Choose (s/n/o)[s]?' |
|---|
| 309 | else |
|---|
| 310 | echo 'Choose (s/n)[s]?' |
|---|
| 311 | |
|---|
| 312 | fi |
|---|
| 313 | read var |
|---|
| 314 | echo |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | case "$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";; |
|---|
| 338 | esac |
|---|
| 339 | |
|---|
| 340 | separator |
|---|
| 341 | echo ">>> Installation Complete" |
|---|
| 342 | |
|---|
| 343 | separator |
|---|
| 344 | SHELL_ANS=0 |
|---|
| 345 | |
|---|
| 346 | while [ "$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 |
|---|
| 410 | done |
|---|
| 411 | |
|---|
| 412 | echo "" |
|---|
| 413 | echo "Note for sysadmins:" |
|---|
| 414 | echo " In order to provide arb for all users," |
|---|
| 415 | echo " edit the global shell init file(s) in /etc" |
|---|
| 416 | echo " (/etc/bash.bashrc, /etc/csh.cshrc or similar)" |
|---|
| 417 | echo " in the same manner as described above for the" |
|---|
| 418 | echo " local shell init files." |
|---|
| 419 | echo "" |
|---|
| 420 | echo "Please read the files" |
|---|
| 421 | echo " $ARBHOME/arb_INSTALL.txt" |
|---|
| 422 | echo " $ARBHOME/arb_UBUNTU.txt (if you're using ubuntu)" |
|---|
| 423 | echo "about additional libraries and tools needed by ARB." |
|---|
| 424 | echo "" |
|---|
| 425 | echo "When you installed everything and performed the changes to your init file," |
|---|
| 426 | echo "open a new terminal window and start arb by typing" |
|---|
| 427 | echo "" |
|---|
| 428 | echo " arb" |
|---|
| 429 | echo "" |
|---|
| 430 | echo "Have much fun using ARB" |
|---|
| 431 | echo "ARB Team <arb@arb-home.de>" |
|---|
| 432 | echo "" |
|---|
| 433 | |
|---|
| 434 | unset host |
|---|
| 435 | unset cwd |
|---|
| 436 | unset ARBHOME |
|---|
| 437 | unset delete_dir |
|---|
| 438 | unset keep_debug |
|---|
| 439 | unset pt_dir |
|---|
| 440 | unset var |
|---|