diff options
-rwxr-xr-x | 4store-install | 43 | ||||
-rwxr-xr-x | base-install (renamed from base-install.sh) | 24 | ||||
-rwxr-xr-x | config.sh | 1 | ||||
-rwxr-xr-x | install | 23 | ||||
-rwxr-xr-x | utils.sh | 49 |
5 files changed, 107 insertions, 33 deletions
diff --git a/4store-install b/4store-install new file mode 100755 index 0000000..a00a07a --- /dev/null +++ b/4store-install @@ -0,0 +1,43 @@ +#!/bin/sh + +# Installs 4store on Debian and compatible systems. +# Author: Andreas Maunz + +DIR=`pwd` + +# Boot +. ./utils.sh || (echo "Utils could not be loaded, check opentox-ui.sh." 1>&2 && exit 1) +SELF=$(basename $0 -install) +check_log $SELF +[ "`id -u`" = "0" ] && echo "This script must not be run as root" 1>&2 && exit 1 +check_utils "git make" + +# Build +cd $OT_PREFIX/tmp/ +([ -d $SELF ] && cd $SELF && cmd="$GIT pull" && run_cmd "$cmd" "Git pull") || (cmd="$GIT clone https://github.com/garlik/$SELF" && run_cmd "$cmd" "Git clone") +cd $SELF +cmd="./autogen.sh" && run_cmd "$cmd" "Autogen" +export FST=$HOME/4S +cmd="./configure --prefix=$FST --exec-prefix=$FST --with-storage-path=$FST/var/lib --with-config-file=$FST/$SELF.conf -with-http-log=$FST/log" && run_cmd "$cmd" "Configure" +cmd="make" && run_cmd "$cmd" "Make" +cmd="make install" && run_cmd "$cmd" "Make Install" +#cmd="make test" && run_cmd "$cmd" "Make Test" + +# Config +echo "if echo \"\$LD_LIBRARY_PATH\" | grep -v \"$FST/lib\">/dev/null 2>&1; then export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$FST/lib\"; fi" >> "$FST_CONF" +echo "$SELF configuration has been stored in '$FST_CONF'." +if ! grep "$FST_CONF" $OT_UI_CONF >/dev/null 2>&1; then + echo '. '$FST_CONF >> $OT_UI_CONF +fi + +# Testing code --- unused +#export LD_LIBRARY_PATH=$FST/lib +#cd $FST +#bin/4s-backend-setup test +#bin/4s-backend test +#bin/4s-httpd -D -H localhost -p 8000 test # -D only for testing + +notify + +# return to wd +cd $DIR diff --git a/base-install.sh b/base-install index c9cebdd..7ce7c70 100755 --- a/base-install.sh +++ b/base-install @@ -6,27 +6,21 @@ # NOTE: Your installed packages are safe and will not be updated. # Java configuration is included in '$OT_UI_CONF'. -. ./utils.sh DIR=`pwd` -if [ "$(id -u)" = "0" ]; then - echo "This script must not be run as root" 1>&2 - exit 1 -fi - -# Utils +# Boot +. ./utils.sh || (echo "Utils could not be loaded, check opentox-ui.sh" 1>&2 && exit 1) +# Not logged +# Not logged +[ "`id -u`" = "0" ] && echo "This script must not be run as root" 1>&2 && exit 1 check_utils "aptitude git apt-cache dpkg" -touch $OT_UI_CONF - # Pkgs -packs="binutils build-essential cmake curl gnuplot hostname libcurl4-openssl-dev libgsl0-dev libopenbabel4 libopenbabel-dev libraptor1-dev libreadline6-dev libreadline-dev libsqlite3-dev libssl-dev libyaml-dev libxml2-dev libxslt1-dev lsb-release openjdk-6-jdk psmisc pwgen raptor-utils r-base r-base-core r-base-dev sqlite3 udev wget xsltproc zlib1g-dev" - +packs="build-essential cmake libgsl0-dev libopenbabel4 libopenbabel-dev libtool openjdk-6-jdk r-base r-base-dev libpcre3-dev librasqal3-dev libtool libraptor1-dev libglib2.0-dev ncurses-dev libreadline-dev uuid-dev" echo echo "Base Packages:" - echo -echo "Updating index" +echo "Updating index..." sudo $APTITUDE update -y >/dev/null 2>&1 pack_arr=$packs @@ -52,7 +46,9 @@ fi echo if [ -n "$pack_arr" ]; then - cmd="sudo $APTITUDE -y install $pack_arr" && run_cmd "$cmd" "Installing packages" + echo + echo "Installing packages" + sudo $APTITUDE -y install $pack_arr fi @@ -23,6 +23,7 @@ RUBY_DWL="http://ftp.ruby-lang.org/pub/ruby/1.9" ### Nothing to gain from changes below this line. JAVA_CONF="$HOME/.opentox/sh_java" +FST_CONF="$HOME/.opentox/sh_4S" OB_CONF="$HOME/.opentox/sh_OB" R_CONF="$HOME/.opentox/sh_R" OT_UI_CONF="$HOME/.opentox/opentox-ui.sh" @@ -1,11 +1,9 @@ #!/bin/sh + # Main Opentox-ruby install script # Author: Christoph Helma, Andreas Maunz -if [ "$(id -u)" = "0" ]; then - echo "This script must not be run as root" 1>&2 - exit 1 -fi +[ "`id -u`" = "0" ] && echo "This script must not be run as root" 1>&2 && exit 1 echo echo "OpenTox Ruby" @@ -41,7 +39,8 @@ echo [ -f $OT_PREFIX/install/utils.sh ] || (cmd="mkdir -p $OT_PREFIX/install && cp utils.sh $OT_PREFIX/install" && run_cmd "$cmd" "Install utils.sh to OT_PREFIX") [ -f $HOME/.opentox/config/install/config.sh ] || (cmd="mkdir -p $HOME/.opentox/config/install && cp config.sh $HOME/.opentox/config/install" && run_cmd "$cmd" "Install config.sh to CONFIG (~/.opentox)") -. ./base-install.sh # Debian specific; disable for others. +. ./base-install # Debian specific; disable this for others. +./4store-install # Download, compile and build 4store. Install to OT_PREFIX. if [ ! -d ~/.rbenv ]; then cmd="$GIT clone git://github.com/sstephenson/rbenv.git ~/.rbenv" && run_cmd "$cmd" "rbenv" @@ -56,15 +55,5 @@ fi [ -f $HOME/.opentox/config/ambit_descriptors.yaml ] || (cmd="cp ambit_descriptors.yaml $HOME/.opentox/config/" && run_cmd "$cmd" "Ambit keys file") [ -f $HOME/.opentox/config/jl_keys.yaml ] || (cmd="cp jl_keys.yaml $HOME/.opentox/config/" && run_cmd "$cmd" "Joelib keys file") -echo -echo "Installation finished." -echo "Destination (OT_PREFIX): '$OT_PREFIX'" -echo -echo "IMPORTANT: How to configure your system:" -echo "IMPORTANT: a) Include '$OT_UI_CONF' in shell startup (e.g. ~/.bashrc)." -echo "IMPORTANT: b) Manually source '$OT_UI_CONF' every time." -echo "IMPORTANT: The command in both cases: '. $OT_UI_CONF'" -echo "IMPORTANT: NOW would be the best time to configure!" -echo -echo "Thank you for your attention." -echo +notify + @@ -6,6 +6,7 @@ # Functions to install ruby and install services with bundler. # Ensures presence of ~/.opentox (CONFIG) and OT_PREFIX. +# create a temporary directory in OT_PREFIX and a log directory in .opentox check_dest() { [ -d "$OT_PREFIX/tmp" ] || mkdir -p "$OT_PREFIX/tmp" @@ -20,11 +21,30 @@ check_dest() fi } +# export a LOG file name +check_log() +{ + local name="$1" + if [ -z "$LOG" ]; then + LOG="$OT_PREFIX/tmp/$name.log" + echo + printf "\033[1m%s\033[m\n" "$name ('$LOG'):" + echo + fi +} + +# run a shell command +# Signal exit status by formatted string +# @param cmd command to execute +# @param title textual description of command +# @example { +# run_cmd "ls" "list dir" +# } run_cmd () { local cmd="$1"; local title="$2" printf "%50s" "$title" - if ! eval $cmd >>$LOG 2>&1 ; then + if ! eval "$cmd" >>$LOG 2>&1 ; then printf " [ \033[31m%s\033[m ]\n" "FAIL" echo "Last 10 lines of log:" tail -10 "$LOG" @@ -34,6 +54,11 @@ run_cmd () } +# stop if required binaries not in path +# @param list of binaries +# @example { +# check_utils "git curl" +# } check_utils() { for u in $1; do eval `echo $u | tr "[:lower:]" "[:upper:]" | tr "-" "_"`=`which $u` || (echo "'$u' missing. Install '$u' first." 1>&2 && exit 1) @@ -41,6 +66,8 @@ check_utils() { } +# install ruby using rbenv +# configure the version in config.sh install_ruby() { printf "\n%50s\n" "RUBY" local DIR=`pwd` @@ -57,7 +84,7 @@ install_ruby() { cmd="$RBENV local $RUBY_NUM_VER" && run_cmd "$cmd" "Rbenv set ruby" } - +# install a ruby gem using bundler install_with_bundler() { printf "\n%50s\n" "INSTALL" check_utils "gem rbenv" @@ -66,7 +93,25 @@ install_with_bundler() { cmd="bundle install" && run_cmd "$cmd" "Install using bundler" } +# emit notification if caller was the shell (the user), see http://goo.gl/grCOk +notify() { + echo + echo "Installation succesful" + echo + if ps -o stat= -p $PPID | grep "s" >/dev/null 2>&1; then + echo "IMPORTANT: How to configure your system:" + echo "IMPORTANT: a) Include '$OT_UI_CONF' in shell startup (e.g. ~/.bashrc)." + echo "IMPORTANT: b) Manually source '$OT_UI_CONF' every time." + echo "IMPORTANT: The command in both cases: '. $OT_UI_CONF'" + echo "IMPORTANT: NOW would be the best time to configure!" + echo + echo "Thank you for your attention." + echo + fi +} + +# Force loading configuration from local, if we are installing for the first time if [ -z "$OT_PREFIX" ]; then . ./config.sh else |