From: martinahansen Date: Wed, 19 Oct 2011 20:34:16 +0000 (+0000) Subject: updated biopieces_installer.sh X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4bb57fda5e415393a6074b13d424d3f0019d6847;p=biopieces.git updated biopieces_installer.sh git-svn-id: http://biopieces.googlecode.com/svn/trunk@1589 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_scripts/biopieces_installer.sh b/bp_scripts/biopieces_installer.sh index f9f74f7..cbe5f9f 100755 --- a/bp_scripts/biopieces_installer.sh +++ b/bp_scripts/biopieces_installer.sh @@ -33,13 +33,40 @@ function echo_red } # Function to output an abort message and exit -function abort +function exit_abort { echo_red "abort" exit } +# Function to output an success message and exit +function exit_success +{ + echo "" + echo_green "Congratulations - you have now installed Biopieces." + echo "" + echo " To list all available Biopieces try 'list_biopieces'" + echo "" + echo " To see the synopsis of a Biopiece try 'read_fastq'" + echo "" + echo " To see the full description and exampels try 'read_fastq -?'" + echo "" + echo " Don't forget to join the Biopieces Google Group for important" + echo " messages, questions, discussion, and suggestions:" + echo "" + echo " http://groups.google.com/group/biopieces" + echo "" + echo " And of cause there is the introduction:" + echo "" + echo " http://code.google.com/p/biopieces/wiki/Introduction" + echo "" + echo " Happy hacking!" + echo "" + + exit +} + # Function to create a directory if it doesn't exist. function dir_create { @@ -52,7 +79,7 @@ function dir_create else echo_red "FAIL" echo $error - abort + exit_abort fi } @@ -71,6 +98,7 @@ function prompt_install echo "" echo " The installer will now do the following:" echo "" + echo " - Check for existing Biopieces installation." echo " - Check prerequisites:" echo " * Subversion client" echo " * Perl" @@ -79,9 +107,9 @@ function prompt_install echo " * Ruby gems" echo " * Auxillary programs" echo "" - echo " - Create installation directories" - echo " - Download code from repository" - echo " - Set environment in .bashrc" + echo " - Create installation directories." + echo " - Download code from repository." + echo " - Set environment in .bashrc." echo " - Run tests" echo "" echo " Problems? Check out the FAQ:" @@ -97,7 +125,93 @@ function prompt_install read -p "Continue (yes/no)? " answer case $answer in [Yy]* ) break;; - [Nn]* ) abort;; + [Nn]* ) exit_abort;; + esac + done +} + +# Function to prompt the checking of any existing Biopieces installation. +function prompt_install_existing +{ + echo "Checking for existing Biopieces installation:" + + if [ $BP_DIR ]; then + echo_yellow " WARNING: \$BP_DIR is already set to: $BP_DIR" + found=1 + fi + + if [ $BP_DATA ]; then + echo_yellow " WARNING: \$BP_DATA is already set to: $BP_DATA" + found=1 + fi + + if [ $BP_TMP ]; then + echo_yellow " WARNING: \$BP_TMP is already set to: $BP_TMP" + found=1 + fi + + if [ $BP_LOG ]; then + echo_yellow " WARNING: \$BP_LOG is already set to: $BP_LOG" + found=1 + fi + + if [ $found ]; then + echo "" + echo " It appears that an old installation of Biopeices exists." + fi + + while true; do + read -p "Continue (yes/no)? " answer + case $answer in + [Yy]* ) break;; + [Nn]* ) exit_abort;; + esac + done +} + +# Function to prompt the testing of prerequisites. +function prompt_test_prerequisites +{ + echo "Testing prerequisites:" + + test_svn + test_perl + test_perl_module "Inline" + test_perl_module "JSON::XS" + test_perl_module "SVG" + test_perl_module "Bit::Vector" + test_perl_module "Time::HiRes" + test_ruby + test_ruby_gem "gnuplot" + test_ruby_gem "narray" + test_aux_program "blastall" + test_aux_program "blat" + test_aux_program "bwa" + test_aux_program "bowtie" + test_aux_program "formatdb" + test_aux_program "gnuplot" + test_aux_program "idba" + test_aux_program "muscle" + test_aux_program "mummer" + test_aux_program "mysql" + test_aux_program "prodigal" + test_aux_program "Ray" + test_aux_program "scan_for_matches" + test_aux_program "uclust" + test_aux_program "velveth" + test_aux_program "velvetg" + test_aux_program "vmatch" + + echo "" + echo " Any WARNINGs indicate that the executable for that auxillary" + echo " program could not be found. While not critical, this will" + echo " cause some Biopieces to fail." + + while true; do + read -p "Continue (yes/no)? " answer + case $answer in + [Yy]* ) break;; + [Nn]* ) exit_abort;; esac done } @@ -114,7 +228,7 @@ function prompt_install_dir_code read -p "Create directory: $bp_code (yes/no)? " answer case $answer in [Yy]* ) dir_create $bp_code && break;; - [Nn]* ) abort;; + [Nn]* ) exit_abort;; esac done fi @@ -132,7 +246,7 @@ function prompt_install_dir_data read -p "Create directory: $bp_data (yes/no)? " answer case $answer in [Yy]* ) dir_create $bp_data && break;; - [Nn]* ) abort;; + [Nn]* ) exit_abort;; esac done fi @@ -150,7 +264,7 @@ function prompt_install_dir_log read -p "Create directory: $bp_log (yes/no)? " answer case $answer in [Yy]* ) dir_create $bp_log && break;; - [Nn]* ) abort;; + [Nn]* ) exit_abort;; esac done fi @@ -168,7 +282,7 @@ function prompt_install_dir_tmp read -p "Create directory: $bp_tmp (yes/no)? " answer case $answer in [Yy]* ) dir_create $bp_tmp && break;; - [Nn]* ) abort;; + [Nn]* ) exit_abort;; esac done fi @@ -177,7 +291,8 @@ function prompt_install_dir_tmp # Function to prompt the appending of a section to bashrc. function prompt_append_bashrc { - section=" + local skip=0 + local section=" # >>>>>>>>>>>>>>>>>>>>>>> Enabling Biopieces <<<<<<<<<<<<<<<<<<<<<<< @@ -192,58 +307,64 @@ source \"\$BP_DIR/bp_conf/bashrc\" " + echo "" + echo "We need to append the below section to your .bashrc file." + echo_yellow "$section" - echo "We need to append the above section to your .bashrc file." while true; do - read -p "Continue (yes/no)? " answer + read -p "Append (yes/no/abort)? " answer case $answer in - [Yy]* ) break;; - [Nn]* ) abort;; + [Yy]* ) skip=0 && break;; + [Nn]* ) skip=1 && break;; + [Aa]* ) exit_abort;; esac done - echo -n "Appending $HOME/.bashrc: " + if [ $skip == 1 ]; then + echo "Skipping" + else + echo -n "Appending $HOME/.bashrc: " - cp "$HOME/.bashrc" "$HOME/.bashrc_biopieces" + cp "$HOME/.bashrc" "$HOME/.bashrc_biopieces" - echo "$section" >> "$HOME/.bashrc" + echo "$section" >> "$HOME/.bashrc" - source "$HOME/.bashrc" + source "$HOME/.bashrc" - echo_green "OK" - echo "" - echo "Backup is $HOME/.bashrc_biopieces" + echo_green "OK" + echo "" + echo " Backup is $HOME/.bashrc_biopieces" + fi } - # Function to test if subversion client is in $PATH. function test_svn { local program="svn" - echo -n "Testing subversion client - \"$program\": " + echo -n " Testing subversion client - \"$program\": " if command -v $program >/dev/null; then echo_green "OK" else echo_red "FAIL" - echo " Subversion client $program was not found." - abort + echo " Subversion client $program was not found." + exit_abort fi } # Function to test if the required version of Perl is installed. function test_perl { - echo -n "Testing Perl version: " + echo -n " Testing Perl version: " if error=$( perl -e 'use 5.8.0;' 2>&1 ); then echo_green "OK" else echo_red "FAIL" echo $error | sed "s/, stopped.*//" - abort + exit_abort fi } @@ -252,12 +373,12 @@ function test_perl_module { local module=$1 - echo -n "Testing required Perl module - \"$module\": " + echo -n " Testing required Perl module - \"$module\": " if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then echo_red "FAIL" echo " Try: perl -MCPAN -e 'install $module'" - abort + exit_abort else echo_green "OK" fi @@ -266,14 +387,14 @@ function test_perl_module # Function to test if the required version of Ruby is installed. function test_ruby { - echo -n "Testing Ruby version: " + echo -n " Testing Ruby version: " if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then echo_green "OK" else echo_red "FAIL" echo $error | sed "s/.*: //" - abort + exit_abort fi } @@ -282,14 +403,14 @@ function test_ruby_gem { local gem=$1 - echo -n "Testing required Ruby gem - \"$gem\": " + echo -n " Testing required Ruby gem - \"$gem\": " if error=$( gem list --local | grep $gem ); then echo_green "OK" else echo_red "FAIL" - echo " Try: gem install $gem" - abort + echo " Try: gem install $gem" + exit_abort fi } @@ -298,7 +419,7 @@ function test_aux_program { local program=$1 - echo -n "Testing auxiliary program - \"$program\": " + echo -n " Testing auxiliary program - \"$program\": " if command -v $program >/dev/null; then echo_green "OK" @@ -317,7 +438,7 @@ function checkout_code else echo_red "FAIL" echo $error - abort + exit_abort fi } @@ -331,54 +452,33 @@ function checkout_wiki else echo_red "FAIL" echo $error - abort + exit_abort fi } -# Function to run the Biopieces test suite. -function run_tests +# Function to run the Biopieces tests. +function prompt_test_biopieces { + echo "Running the Biopieces test suite:" + echo "" + + "$BP_DIR/bp_test/test_all" + + echo "" + echo " Any FAIL indicates broken Biopieces - seek help!" + while true; do - read -p "Run the Biopieces test suite (yes/no)? " answer + read -p "Continue (yes/no)? " answer case $answer in - [Yy]* ) "$BP_DIR/bp_test/test_all" && break;; - [Nn]* ) break;; + [Yy]* ) break;; + [Nn]* ) exit_abort;; esac done } prompt_install - -test_svn -test_perl -test_perl_module "Inline" -test_perl_module "JSON::XS" -test_perl_module "SVG" -test_perl_module "Bit::Vector" -test_perl_module "Time::HiRes" -test_ruby -test_ruby_gem "gnuplot" -test_ruby_gem "narray" -test_aux_program "blastall" -test_aux_program "blat" -test_aux_program "bwa" -test_aux_program "bowtie" -test_aux_program "formatdb" -test_aux_program "gnuplot" -test_aux_program "idba" -test_aux_program "muscle" -test_aux_program "mummer" -test_aux_program "mysql" -test_aux_program "prodigal" -test_aux_program "Ray" -test_aux_program "scan_for_matches" -test_aux_program "uclust" -test_aux_program "velveth" -test_aux_program "velvetg" -test_aux_program "vmatch" - -echo "" - +prompt_install_existing +prompt_test_prerequisites prompt_install_dir_code prompt_install_dir_data prompt_install_dir_log @@ -388,28 +488,6 @@ checkout_code checkout_wiki prompt_append_bashrc +prompt_test_biopieces -run_tests - -echo "" -echo_green "Congratulations - you have now installed Biopieces." -echo "" -echo " To list all available Biopieces try 'list_biopieces'" -echo "" -echo " To see the synopsis of a Biopiece try 'read_fastq'" -echo "" -echo " To see the full description and exampels try 'read_fastq -?'" -echo "" -echo " Don't forget to join the Biopieces Google Group for important" -echo " messages, questions, discussion, and suggestions:" -echo "" -echo " http://groups.google.com/group/biopieces" -echo "" -echo " And of cause there is the introduction:" -echo "" -echo " http://code.google.com/p/biopieces/wiki/Introduction" -echo "" -echo " Happy hacking!" -echo "" - -exit +exit_success