summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-05-23 13:32:35 +0200
committermr <mr@mrautenberg.de>2011-05-23 13:32:35 +0200
commit565997933b51f4573b68c2f04ebff82755ea8c74 (patch)
treea65f1c14b32e36be889f5724be82bfb9c103d684
parenta8efedb2177909693dbd51409492f8ac8418b3cb (diff)
parentccdba9f5223d82873b1c653ea3f8635f18fefd0e (diff)
Merge branch 'release/2.0.0'v2.0.0
-rw-r--r--README68
-rw-r--r--aa-local.yaml17
-rw-r--r--aa-server.yaml17
-rwxr-xr-xbase-install.sh96
-rw-r--r--config23
-rwxr-xr-xconfig.sh50
-rw-r--r--debian.sh23
-rwxr-xr-xinstall48
-rwxr-xr-x[-rw-r--r--]kernlab.sh75
-rw-r--r--nginx.conf13
-rwxr-xr-x[-rw-r--r--]nginx.sh74
-rwxr-xr-x[-rw-r--r--]openbabel.sh110
-rw-r--r--opentox-ruby.sh123
-rwxr-xr-x[-rw-r--r--]opentox-webservices.sh99
-rw-r--r--production.yaml4
-rwxr-xr-x[-rw-r--r--]redis.sh86
-rwxr-xr-x[-rw-r--r--]ruby.sh93
-rwxr-xr-xutils.sh41
18 files changed, 842 insertions, 218 deletions
diff --git a/README b/README
index 3c85262..8d26ed8 100644
--- a/README
+++ b/README
@@ -1,19 +1,59 @@
-Installer for OpenTox IST/ALU Services
-======================================
+POSIX compatible Installer for OpenTox IST/ALU Services
+=======================================================
-Usage
------
+A) It is assumed that your system is configured for sudo to gain root privileges.
+B) It is assumed that your system is configured for using non-free packages.
-tested with Debian Squeeze, might work for Ubuntu and other Debian based distributions
+This is a POSIX-compliant (not limited to a particular shell) Opentox installer. Please report bugs always via GitHub.
- git clone http://github.com/opentox/install.git
- cd install
- vi config
- sudo ./install
+Here are some of my goals when writing the installer:
+- Safe (existence of all the binaries will be checked before running, apart from GNU Core Utils)
+- Idempotent (multiple execution does not change a thing)
+- Atomic (return value of each non-elemtary action is asserted to be TRUE)
+- Encapsulated (everything is installed in a sub-directory in $HOME)
+- Logged (all non-elemtary actions are logged)
-Adjusting for other distributions
----------------------------------
+Even if we officially support only *one* distro (currently Debian 6.0.1), I tested the installer successfully on various Ubuntus. In the README at the top are the requirements of the installer. By default, everything is installed to $HOME/opentox-ruby (=OT_PREFIX). The configs go to OT_PREFIX/.sh_<Package>_ot.sh for each package.
-- Create a script {distribution}.sh that installs all dependencies and libraries
-- Set {distribution} in config
-- Run sudo ./install
+After running the installer, configure the system by editing the startup file of your favorite shell (in my case, BASH with the file ~ /. bashrc) to include ~/.opentox-ui.sh (in my case with 'source ...'). This file is the only one that the installer creates outside OT_PREFIX. Thus, the system is fully configured: If you now open a new shell, all environment variables will be adjusted.
+
+To start the system I run the following (but that is not part of the installer):
+sudo nohup ~/opentox-ruby/redis-2.2.2/src/redis-server ~/opentox-ruby/redis-2.2.2/redis.conf &
+sudo nohup ~/opentox-ruby/nginx/sbin/nginx -c ~/opentox-ruby/nginx/conf/nginx.conf &
+
+To uninstall the system simply delete the link from the startup file: Done. To save disc space delete directory OT_PREFIX.
+Anyone can run multiple Opentox versions on the same machine: Just install again, but to a different OT_PREFIX. The switch works manually: Include the sh_<Package>_ot.sh files from the desired OT_PREFIX in ~/opentox-ui.sh (only one installation may be activated at any time).
+
+Some useful scripts to put in your ~/.bashrc in case you are using bash (assuming OT_PREFIX is '~/opentox-ruby'):
+
+# Load server config
+otconfig() {
+ source ~/.opentox-ui.sh
+}
+
+# Start the server
+otstart() {
+ otkill
+ sudo bash -c "source ~/.opentox-ui.sh; nohup redis-server ~/opentox-ruby/redis-2.2.2/redis.conf >/dev/null 2>&1 &"
+ sudo bash -c "source ~/.opentox-ui.sh; nohup nginx -c ~/opentox-ruby/nginx/conf/nginx.conf >/dev/null 2>&1 &"
+ sleep 2
+ if ! pgrep nginx>/dev/null 2>&1; then echo "Failed to start nginx."; fi
+ if ! pgrep redis-server>/dev/null 2>&1; then echo "Failed to start redis."; fi
+}
+
+# Display log
+alias otless='less ~/.opentox/log/production.log'
+
+# Tail log
+alias ottail='tail -f ~/.opentox/log/production.log'
+
+# Reload the server
+otreload() {
+ sudo bash -c "source ~/.opentox-ui.sh; nginx -s reload"
+}
+
+# Kill the server
+otkill() {
+ sudo killall nginx >/dev/null 2>&1
+ sudo bash -c "source ~/.opentox-ui.sh; redis-cli shutdown >/dev/null 2>&1"
+}
diff --git a/aa-local.yaml b/aa-local.yaml
index 593ba56..c01c1ed 100644
--- a/aa-local.yaml
+++ b/aa-local.yaml
@@ -15,24 +15,23 @@
# Exceptions:
:free_uris: #request-method for uri not controlled by A&A
? - :GET
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/algorithm/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/algorithm/
- "http://SERVERNAME/model"
- "http://SERVERNAME/validation"
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/validation\/[a-z,A-Z,\/,_\-]*$/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/validation\/[a-z,A-Z,\/,_\-]*$/
? - :GET
- :POST
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/toxcreate/
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/task/
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/compound/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/toxcreate/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/task/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/compound/
? - :PUT
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/task/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/task/
:authorize_exceptions: #request-method for uri only authenticated, no authorization
? - :POST
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/algorithm/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/algorithm/
- "http://SERVERNAME/dataset"
- "http://SERVERNAME/model"
- "http://SERVERNAME/validation"
- - !ruby/regexp /http\:\/\/ESCAPEDSERVERNAME\/validation\/[a-z,A-Z,\/,_\-]*$/
-
+ - !ruby/regexp /http\:\/\/ESCAPEDSERVER\/validation\/[a-z,A-Z,\/,_\-]*$/
diff --git a/aa-server.yaml b/aa-server.yaml
index 593ba56..c01c1ed 100644
--- a/aa-server.yaml
+++ b/aa-server.yaml
@@ -15,24 +15,23 @@
# Exceptions:
:free_uris: #request-method for uri not controlled by A&A
? - :GET
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/algorithm/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/algorithm/
- "http://SERVERNAME/model"
- "http://SERVERNAME/validation"
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/validation\/[a-z,A-Z,\/,_\-]*$/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/validation\/[a-z,A-Z,\/,_\-]*$/
? - :GET
- :POST
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/toxcreate/
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/task/
- - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/compound/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/toxcreate/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/task/
+ - !ruby/regexp /http:\/\/ESCAPEDSERVER\/compound/
? - :PUT
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/task/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/task/
:authorize_exceptions: #request-method for uri only authenticated, no authorization
? - :POST
- : - !ruby/regexp /http:\/\/ESCAPEDSERVERNAME\/algorithm/
+ : - !ruby/regexp /http:\/\/ESCAPEDSERVER\/algorithm/
- "http://SERVERNAME/dataset"
- "http://SERVERNAME/model"
- "http://SERVERNAME/validation"
- - !ruby/regexp /http\:\/\/ESCAPEDSERVERNAME\/validation\/[a-z,A-Z,\/,_\-]*$/
-
+ - !ruby/regexp /http\:\/\/ESCAPEDSERVER\/validation\/[a-z,A-Z,\/,_\-]*$/
diff --git a/base-install.sh b/base-install.sh
new file mode 100755
index 0000000..0a13c68
--- /dev/null
+++ b/base-install.sh
@@ -0,0 +1,96 @@
+#!/bin/sh
+#
+# Installs base packages for Ubuntu
+# Author: Andreas Maunz
+#
+# Your installed packages are safe and will not be updated.
+# A Java configuration is created and included in your '$OT_UI_CONF'.
+
+. "`pwd`/utils.sh"
+DIR="`pwd`"
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must not be run as root" 1>&2
+ exit 1
+fi
+
+# Utils
+APTITUDE="`which aptitude`"
+APT_CACHE="`which apt-cache`"
+DPKG="`which dpkg`"
+
+if [ ! -e "$APTITUDE" ]; then
+ echo "Aptitude missing. Install aptitude first." 1>&2
+ exit 1
+fi
+
+touch $OT_UI_CONF
+
+# Pkgs
+packs="binutils build-essential git-core gnuplot hostname libcurl4-openssl-dev libgsl0-dev libreadline5-dev libreadline-dev libsqlite3-dev libssl-dev libxml2-dev libxslt1-dev lsb-release pwgen raptor-utils r-base r-base-core r-base-dev sqlite3 sun-java6-jdk wget xsltproc zlib1g-dev"
+
+echo
+echo "Base Packages:"
+
+pack_arr=""
+for p in $packs; do
+ if $DPKG -s "$p" >/dev/null 2>&1; then
+ printf "%50s%30s\n" "'$p'" "Y"
+ else
+ printf "%50s%30s\n" "'$p'" "N"
+ pack_arr="$pack_arr $p"
+ fi
+done
+
+if [ -n "$pack_arr" ]; then
+ echo
+ echo "Checking availablity:"
+ sudo $APTITUDE update -y >/dev/null 2>&1
+# sudo $APTITUDE upgrade -y >/dev/null 2>&1
+fi
+
+for p in $pack_arr; do
+ if [ -n "`$APT_CACHE search $p`" ] ; then
+ printf "%50s%30s\n" "'$p'" "Y"
+ else
+ printf "%50s%30s\n" "'$p'" "N"
+ pack_fail="$pack_fail $p"
+ fi
+done
+
+if [ -n "$pack_fail" ]; then
+ echo
+ echo "WARNING: At least one missing package has no suitable installation candidate."
+ echo "Press <Ctrl+C> to abort (5 sec)."
+ sleep 5
+fi
+
+echo sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true | sudo /usr/bin/debconf-set-selections
+echo
+if [ -n "$pack_arr" ]; then
+ echo "Installing missing packages:"
+fi
+
+for p in $pack_arr; do
+ cmd="sudo $APTITUDE -y install $p" && run_cmd "$cmd" "$p"
+done
+
+if [ ! -f $JAVA_CONF ]; then
+
+ if [ ! -d "$OT_JAVA_HOME" ]; then
+ echo "Directory '$OT_JAVA_HOME' does not exist! Aborting..."
+ exit 1
+ fi
+
+ echo "if echo \"\$JAVA_HOME\" | grep -v \"$OT_JAVA_HOME\">/dev/null 2>&1; then export JAVA_HOME=\"$OT_JAVA_HOME\"; fi" >> "$JAVA_CONF"
+ echo "if echo \"\$PATH\" | grep -v \"$OT_JAVA_HOME\">/dev/null 2>&1; then export PATH=\"$OT_JAVA_HOME:\$PATH\"; fi" >> "$JAVA_CONF"
+ echo "if ! [ -d \"\$JAVA_HOME\" ]; then echo \"\$0: '\$OT_JAVA_HOME' is not a directory!\"; fi" >> "$JAVA_CONF"
+
+ echo "Java configuration has been stored in '$JAVA_CONF'."
+ if ! grep "$JAVA_CONF" $OT_UI_CONF >/dev/null 2>&1; then
+ echo ". \"$JAVA_CONF\"" >> $OT_UI_CONF
+ fi
+fi
+
+cd "$DIR"
+
diff --git a/config b/config
deleted file mode 100644
index b5dabcc..0000000
--- a/config
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-# Configuration options for OpenTox installations (sets shell variables for installation scripts)
-
-# Linux distribution (currently only debian)
-distribution=debian
-
-# Choose a root password for the MySQL database
-# Please insert the correct password if mysql-server is already installed
-mysql_root=opentox
-
-# Installation type
-# Options:
-# gem installs only the opentox-ruby gem (useful, if you want to use external services with the opentox-ruby DSL)
-# local local installation (authentication and authorisation disabled)
-# server inter or intranet server (authentication and authorisation enabled)
-install=server
-
-# Git branch of services
-# Options: master development
-# "master" installs the current stable version
-branch=master
-
diff --git a/config.sh b/config.sh
new file mode 100755
index 0000000..5a13b3a
--- /dev/null
+++ b/config.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Configuration file for Opentox installer.
+# Author: Christoph Helma, Andreas Maunz.
+#
+
+# 1) Base setup
+OT_DIST="debian" # Linux distribution (debian)
+OT_INSTALL="local" # Type (gem, local, server)
+OT_BRANCH="master" # Maturity (development, master)
+
+# 2) Where all binaries are installed.
+OT_PREFIX="$HOME/opentox-ruby"
+OT_JAVA_HOME="/usr/lib/jvm/java-6-sun"
+
+# 3) What versions to install.
+RUBY_NUM_VER="1.8.7-2011.03"
+OB_NUM_VER="2.2.3"
+KL_NUM_VER="0.9-11"
+REDIS_NUM_VER="2.2.2"
+
+# 4) Server settings.
+NGINX_SERVERNAME="localhost"
+WWW_DEST="$OT_PREFIX/www"
+
+# Done.
+
+
+### Nothing to gain from changes below this line.
+JAVA_CONF="$OT_PREFIX/.sh_java_ot"
+RUBY_CONF="$OT_PREFIX/.sh_ruby_ot"
+REDIS_CONF="$OT_PREFIX/.sh_redis_ot"
+NGINX_CONF="$OT_PREFIX/.sh_nginx_ot"
+OB_CONF="$OT_PREFIX/.sh_OB_ot"
+KL_CONF="$OT_PREFIX/.sh_R_ot"
+
+RUBY_VER="ruby-enterprise-$RUBY_NUM_VER"
+OB_VER="openbabel-$OB_NUM_VER"
+KL_VER="$KL_NUM_VER"
+REDIS_VER="$REDIS_NUM_VER"
+
+RUBY_DEST="$OT_PREFIX/$RUBY_VER"
+OB_DEST="$OT_PREFIX/$OB_VER"
+OB_DEST_BINDINGS="$OT_PREFIX/openbabel-ruby-install"
+KL_DEST="$OT_PREFIX/r-packages"
+NGINX_DEST="$OT_PREFIX/nginx"
+REDIS_DEST="$OT_PREFIX/redis-$REDIS_VER"
+
+REDIS_SERVER_CONF="$REDIS_DEST/redis.conf"
+OT_UI_CONF="$HOME/.opentox-ui.sh"
diff --git a/debian.sh b/debian.sh
deleted file mode 100644
index 7102a5e..0000000
--- a/debian.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-echo "Downloading and updating Debian packages"
-echo "deb http://ftp.de.debian.org/debian squeeze main contrib
-deb http://ftp.de.debian.org/debian/ squeeze non-free" > /etc/apt/sources.list
-
-apt-get install lsb-release
-codename=`lsb_release -a|grep Codename|cut -f2`
-if ! grep "^deb.*debian\.org.*non-free" /etc/apt/sources.list
-then
- echo "deb http://ftp.debian.org/debian/ $codename non-free" | tee -a /etc/apt/sources.list
-fi
-apt-get update -y
-apt-get upgrade -y
-apt-get install binutils gcc g++ gfortran wget hostname pwgen git-core raptor-utils r-base -y
-# accept java license automatically
-echo sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true | /usr/bin/debconf-set-selections
-apt-get install --yes sun-java6-jdk -y
-. ./config
-#apt-get install xsltproc gnuplot -y # for validation
-apt-get install libssl-dev zlib1g-dev libreadline-dev libmysqlclient-dev libmysqlclient-dev libcurl4-openssl-dev libxml2-dev libxslt1-dev libgsl0-dev -y
-sed -i '/^JAVA_HOME=/d' /etc/profile
-echo 'export JAVA_HOME=/usr/lib/jvm/java-6-sun' | tee -a /etc/profile
diff --git a/install b/install
index 9e72d13..6a1e84f 100755
--- a/install
+++ b/install
@@ -1,20 +1,40 @@
#!/bin/sh
+# Main Opentox-ruby install script
+# Author: Christoph Helma, Andreas Maunz
-. ./config
-. ./$distribution.sh
-. ./ruby.sh
-. ./openbabel.sh
-. ./kernlab.sh
-. ./opentox-ruby.sh
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must not be run as root" 1>&2
+ exit 1
+fi
+
+LOG="/tmp/`basename $0`-log.txt"
+. "./utils.sh"
+echo
+echo "Opentox-ruby installation."
+echo "You may need to give root password for some privileged actions right now and later:"
+echo
+cmd="sudo echo -n \"\"" && run_cmd "$cmd" "Acquire privileges"
+
+echo "Cleaning up /tmp files."
+sudo rm -rf /tmp/openbabel* /tmp/kernlab* /tmp/ruby* /tmp/passenger*
+
+. "./base-install.sh"
+. "./ruby.sh"
+. "./openbabel.sh"
+. "./kernlab.sh"
+. "./opentox-ruby.sh"
-if [ $install != "gem" ]
+if [ "$install" != "gem" ]
then
- . ./nginx.sh
- . ./redis.sh
- . ./opentox-webservices.sh
- #. ./mysql-setup.sh
- echo "Starting Nginx"
- echo "Please inspect and tune /opt/nginx/conf/nginx.conf and /home/opentox/.opentox/config/production.yaml"
- /opt/nginx/sbin/nginx
+ . "./nginx.sh"
+ . "./redis.sh"
+ . "./opentox-webservices.sh"
fi
+echo
+echo "Installation finished and system configured."
+echo "Destination: '$OT_PREFIX'"
+echo "Nginx: '$NGINX_DEST'"
+echo "Redis: '$REDIS_DEST'"
+echo "IMPORTANT: Include the file '$OT_UI_CONF' in your shell or system startup to have the system automatically configured."
+echo
diff --git a/kernlab.sh b/kernlab.sh
index db0c93d..2fba2a8 100644..100755
--- a/kernlab.sh
+++ b/kernlab.sh
@@ -1,8 +1,71 @@
#!/bin/sh
+#
+# Installs Kernlab.
+# Author: Christoph Helma, Andreas Maunz.
+#
+
+. "`pwd`/utils.sh"
+DIR="`pwd`"
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+WGET="`which wget`"
+if [ ! -e "$WGET" ]; then
+ echo "'wget' missing. Install 'wget' first. Aborting..."
+ exit 1
+fi
+
+R="`which R`"
+if [ ! -e "$R" ]; then
+ echo "'R' missing. Install 'R' first. Aborting..."
+ exit 1
+fi
+
+# Pkg
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Kernlab ('$LOG')."
+
+R_DONE=false
+mkdir "$KL_DEST" >/dev/null 2>&1
+if [ ! -d "$KL_DEST" ]; then
+ echo "Install directory '$KL_DEST' is not available! Aborting..."
+ exit 1
+else
+ if ! rmdir "$KL_DEST" >/dev/null 2>&1; then # if not empty this will fail
+ R_DONE=true
+ else
+ mkdir "$KL_DEST" >/dev/null 2>&1
+ fi
+fi
+
+
+if ! $R_DONE; then
+ cd /tmp
+ URI="http://cran.r-project.org/src/contrib/Archive/kernlab/kernlab_$KL_VER.tar.gz"
+ cmd="$WGET $URI" && run_cmd "$cmd" "Download"
+
+ export R_LIBS="$KL_DEST" # To install non-global
+ cmd="$R CMD INSTALL kernlab_$KL_VER.tar.gz" && run_cmd "$cmd" "Install"
+fi
+
+
+if [ ! -f $KL_CONF ]; then
+
+ echo "if echo \"\$R_LIBS\" | grep -v \"$KL_DEST\">/dev/null 2>&1; then export R_LIBS=\"$KL_DEST\"; fi" >> "$KL_CONF"
+ echo "if ! [ -d \"$KL_DEST\" ]; then echo \"\$0: '$KL_DEST' is not a directory!\"; fi" >> "$KL_CONF"
+ echo "R package destination has been stored in '$KL_CONF'."
+
+ if ! grep "$KL_CONF" $OT_UI_CONF >/dev/null 2>&1 ; then
+ echo ". \"$KL_CONF\"" >> $OT_UI_CONF
+ fi
+
+fi
+
+cd "$DIR"
-echo "Installing kernlab"
-. /etc/profile
-cd /tmp
-wget http://cran.r-project.org/src/contrib/Archive/kernlab/kernlab_0.9-11.tar.gz
-R CMD INSTALL kernlab_0.9-11.tar.gz
-cd -
diff --git a/nginx.conf b/nginx.conf
index ce00e37..d3a8324 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -8,14 +8,14 @@ http {
server_names_hash_bucket_size 256;
- passenger_root /opt/ruby-enterprise-1.8.7-2010.03/lib/ruby/gems/1.8/gems/PASSENGER;
- passenger_ruby /opt/ruby-enterprise-1.8.7-2010.03/bin/ruby;
+ passenger_root RUBY_DEST/lib/ruby/gems/1.8/gems/PASSENGER;
+ passenger_ruby RUBY_DEST/bin/ruby;
passenger_default_user opentox;
passenger_log_level 2;
passenger_spawn_method conservative;
#passenger_use_global_queue on;
- include mime.types;
+ include NGINX_DEST/conf/mime.types;
default_type application/octet-stream;
sendfile on;
@@ -26,9 +26,10 @@ http {
listen 80;
client_max_body_size 5000m;
server_name SERVERNAME;
- root /var/www/;
-
- passenger_enabled on;
+ location / {
+ root WWW_DEST;
+ passenger_enabled on;
+ }
passenger_base_uri /compound;
passenger_base_uri /dataset;
passenger_base_uri /algorithm;
diff --git a/nginx.sh b/nginx.sh
index 09eebee..6b10a5c 100644..100755
--- a/nginx.sh
+++ b/nginx.sh
@@ -1,11 +1,69 @@
#!/bin/sh
+#
+# Installs Passenger.
+# Author: Christoph Helma, Andreas Maunz.
+#
-. /etc/profile
-passenger-install-nginx-module --auto-download --auto --prefix=/opt/nginx
+. "`pwd`/utils.sh"
+DIR="`pwd`"
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+PIN="`which passenger-install-nginx-module`"
+if [ ! -e "$PIN" ]; then
+ echo "'passenger-install-nginx-module' missing. Install 'passenger-install-nginx-module' first. Aborting..."
+ exit 1
+fi
+
+GIT="`which git`"
+if [ ! -e "$GIT" ]; then
+ echo "'git' missing. Install 'git' first. Aborting..."
+ exit 1
+fi
+
+
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Nginx ('$LOG'):"
+
+NGINX_DONE=false
+mkdir "$NGINX_DEST" >/dev/null 2>&1
+if [ ! -d "$NGINX_DEST" ]; then
+ echo "Install directory '$NGINX_DEST' is not available! Aborting..."
+ exit 1
+else
+ if ! rmdir "$NGINX_DEST" >/dev/null 2>&1; then # if not empty this will fail
+ NGINX_DONE=true
+ fi
+fi
+
+if ! $NGINX_DONE; then
+ cmd="$PIN --auto-download --auto --prefix=$NGINX_DEST" && run_cmd "$cmd" "Install"
+fi
+
+cd "$RUBY_DEST/lib/ruby/gems/1.8/gems/" >>$LOG 2>&1
+passenger=`ls -d passenger*`
+cd - >>$LOG 2>&1
+servername=`hostname`
+$GIT checkout nginx.conf>>$LOG 2>&1
+cmd="sed -i -e \"s,PASSENGER,$passenger,;s,SERVERNAME,$servername,;s,RUBY_DEST,$RUBY_DEST,;s,NGINX_DEST,$NGINX_DEST,;s,WWW_DEST,$WWW_DEST,\" ./nginx.conf" && run_cmd "$cmd" "Config"
+cmd="cp ./nginx.conf \"$NGINX_DEST/conf\"" && run_cmd "$cmd" "Copy"
+
+if [ ! -f $NGINX_CONF ]; then
+ echo "if ! echo \"\$PATH\" | grep \"$NGINX_DEST\">/dev/null 2>&1; then export PATH=$NGINX_DEST/sbin:\$PATH; fi" >> "$NGINX_CONF"
+ echo "Nginx configuration has been stored in '$NGINX_CONF'."
+
+ if ! grep ". \"$NGINX_CONF\"" $OT_UI_CONF; then
+ echo ". \"$NGINX_CONF\"" >> $OT_UI_CONF
+ fi
+
+fi
+
+
+cd "$DIR"
-cd /opt/ruby-enterprise-1.8.7-2010.03/lib/ruby/gems/1.8/gems/
-passenger=`ls -d passenger*`;
-cd -
-servername=`hostname`.`dnsdomainname`
-echo $passenger
-sed -e "s/PASSENGER/$passenger/;s/SERVERNAME/$servername/" nginx.conf > /opt/nginx/conf/nginx.conf
diff --git a/openbabel.sh b/openbabel.sh
index a1d90a4..3257146 100644..100755
--- a/openbabel.sh
+++ b/openbabel.sh
@@ -1,15 +1,99 @@
#!/bin/sh
+#
+# Installs Openbabel.
+# A configuration file is created and included in your '$OT_UI_CONF'.
+# Author: Christoph Helma, Andreas Maunz.
+#
+
+. "`pwd`/utils.sh"
+DIR="`pwd`"
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+WGET="`which wget`"
+if [ ! -e "$WGET" ]; then
+ echo "'wget' missing. Install 'wget' first. Aborting..."
+ exit 1
+fi
+
+# Pkg
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Openbabel ('$OB_DEST', '$LOG'):"
+
+
+mkdir "$OB_DEST" >/dev/null 2>&1
+if [ ! -d "$OB_DEST" ]; then
+ echo "Install directory '$OB_DEST' is not available! Aborting..."
+ exit 1
+else
+ if ! rmdir "$OB_DEST" >/dev/null 2>&1; then # if not empty this will fail
+ OB_DONE=true
+ fi
+fi
+
+if [ ! $OB_DONE ]; then
+ cd "/tmp">>$LOG 2>/dev/null
+ URI="http://downloads.sourceforge.net/project/openbabel/openbabel/$OB_NUM_VER/$OB_VER.tar.gz?use_mirror=kent"
+ if ! [ -d "/tmp/$OB_VER" ]; then
+ cmd="$WGET $URI" && run_cmd "$cmd" "Download"
+ cmd="tar zxf $OB_VER.tar.gz?use_mirror=kent $OB_VER" && run_cmd "$cmd" "Unpack"
+ fi
+ cd "/tmp/$OB_VER">>$LOG 2>/dev/null
+
+ cmd="./configure --prefix=$OB_DEST" && run_cmd "$cmd" "Configure"
+ cmd="make" && run_cmd "$cmd" "Make"
+ cmd="make install" && run_cmd "$cmd" "Install"
+fi
+
+if [ ! -f "$OB_CONF" ]; then
+
+ echo "if echo \"\$PATH\" | grep -v \"$OB_DEST\">/dev/null 2>&1; then export PATH=\"$OB_DEST/bin:\$PATH\"; fi" >> "$OB_CONF"
+ echo "if echo \"\$LD_LIBRARY_PATH\" | grep -v \"$OB_DEST\">/dev/null 2>&1; then export LD_LIBRARY_PATH=\"$OB_DEST/lib:\$LD_LIBRARY_PATH\"; fi" >> "$OB_CONF"
+ echo "if ! [ -d \"$OB_DEST\" ]; then echo \"\$0: '$OB_DEST' is not a directory!\"; fi" >> "$OB_CONF"
+
+ echo "if [ -z \"\$BABEL_LIBDIR\" ]; then export BABEL_LIBDIR=\"$OB_DEST/lib/openbabel/$OB_NUM_VER\"; fi" >> "$OB_CONF"
+ echo "if ! [ -d \"\$BABEL_LIBDIR\" ]; then echo \"\$0: '\$BABEL_LIBDIR' is not a directory!\"; fi" >> "$OB_CONF"
+
+ echo "if [ -z \"\$BABEL_DATADIR\" ]; then export BABEL_DATADIR=\"$OB_DEST/share/openbabel/$OB_NUM_VER\"; fi" >> "$OB_CONF"
+ echo "if ! [ -d \"\$BABEL_DATADIR\" ]; then echo \"\$0: '\$BABEL_DATADIR' is not a directory!\"; fi" >> "$OB_CONF"
+
+ echo "if echo \"\$RUBYLIB\" | grep -v \"$OB_DEST_BINDINGS\">/dev/null 2>&1; then export RUBYLIB=\"$OB_DEST_BINDINGS:\$RUBYLIB\"; fi" >> "$RUBY_CONF"
+ echo "if ! [ -d \"$OB_DEST_BINDINGS\" ]; then echo \"\$0: '$OB_DEST_BINDINGS' is not a directory!\"; fi" >> "$RUBY_CONF"
+
+ echo "Openbabel configuration has been stored in '$OB_CONF'."
+ if ! grep "$OB_CONF" $OT_UI_CONF >/dev/null 2>&1 ; then
+ echo ". \"$OB_CONF\"" >> $OT_UI_CONF
+ fi
+
+fi
+
+echo "Bindings:"
+OB_DONE=false
+. "$OT_UI_CONF"
+mkdir "$OB_DEST_BINDINGS">/dev/null 2>&1
+if [ ! -d "$OB_DEST_BINDINGS" ]; then
+ echo "Install directory '$OB_DEST_BINDINGS' is not available! Aborting..."
+ exit 1
+else
+ if [ "`ls $OB_DEST_BINDINGS | wc -l`" -gt 0 ]; then
+ OB_DONE=true
+ fi
+fi
+
+if ! $OB_DONE ; then
+ cd "/tmp/$OB_VER/scripts/ruby/"
+ cmd="ruby extconf.rb --with-openbabel-include=$OB_DEST/include/openbabel-2.0 --with-openbabel-lib=$OB_DEST/lib" && run_cmd "$cmd" "Code"
+ cmd="make" && run_cmd "$cmd" "Make"
+ cmd="cp openbabel.so $OB_DEST_BINDINGS" && run_cmd "$cmd" "Install"
+ cmd="ln -s $OB_DEST_BINDINGS/openbabel.so $RUBY_DEST/lib/ruby/site_ruby/1.8/`uname -m`-linux/" && run_cmd "$cmd" "Link"
+fi
+
+cd "$DIR"
+
-echo "Installing OpenBabel libraries"
-. /etc/profile
-dir=`pwd`
-cd /tmp
-wget -O - "http://downloads.sourceforge.net/project/openbabel/openbabel/2.2.3/openbabel-2.2.3.tar.gz?use_mirror=kent" | tar zxv
-cd openbabel-2.2.3/
-./configure
-make install
-cd scripts/ruby/
-ruby extconf.rb --with-openbabel-include=/usr/local/include/openbabel-2.0
-make install
-ldconfig
-cd $dir
diff --git a/opentox-ruby.sh b/opentox-ruby.sh
index 6302009..5f8cc65 100644
--- a/opentox-ruby.sh
+++ b/opentox-ruby.sh
@@ -1,49 +1,90 @@
#!/bin/sh
+#
+# Installs Opentox-ruby gem.
+# Author: Christoph Helma, Andreas Maunz.
+#
-echo "Installing opentox-ruby gem"
-. /etc/profile
-. ./config
-gem install opentox-ruby
-gem install builder # not included by spreadsheet gem
+. "`pwd`/utils.sh"
+DIR="`pwd`"
-dir=`pwd`
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+GIT="`which git`"
+if [ ! -e "$GIT" ]; then
+ echo "'git' missing. Install 'git' first. Aborting..."
+ exit 1
+fi
+
+GEM="`which gem`"
+if [ ! -e "$GEM" ]; then
+ echo "'gem' missing. Install 'gem' first. Aborting..."
+ exit 1
+fi
+
+RAKE="`which rake`"
+if [ ! -e "$RAKE" ]; then
+ echo "'rake' missing. Install 'rake' first. Aborting..."
+ exit 1
+fi
+
+
+# Pkg
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Opentox-ruby ('$LOG'):"
+
+for mygem in opentox-ruby builder jeweler; do
+ if ! $GEM list | grep "$mygem" >/dev/null 2>&1; then
+ cmd="$GEM install $mygem" && run_cmd "$cmd" "$mygem"
+ fi
+done
-# create config file
-servername=`hostname`.`dnsdomainname`
-escapedservername=`echo $servername|sed 's/\/\\\//'`
-if [ $branch = "development" ]
-then
- logger=":logger: backtrace"
+
+servername="`hostname`"
+serverdomain="`dnsdomainname`"
+if [ -n "$serverdomain" ]; then
+ servername="$servername"."$serverdomain"
+fi
+escapedserver="`echo $servername | sed 's/\/\\\//'`"
+
+if [ "$OT_BRANCH" = "development" ]; then
+ logger=":logger: backtrace"
else
- logger=""
+ logger=""
fi
-if [ $install = "server" ]
-then
- aa="https:\/\/opensso.in-silico.ch"
+if [ "$OT_INSTALL" = "server" ]; then
+ aa="https:\/\/opensso.in-silico.ch"
else
- aa=nil
-fi
-
-mkdir -p $HOME/.opentox/config
-mkdir -p $HOME/.opentox/log
-#sed -e "s/SERVERNAME/$servername/;s/LOGGER/$logger/;s/AA/$aa/" production.yaml > $HOME/.opentox/config/production.yaml
-sed -e "s/PASSWORD/$password/;s/SERVERNAME/$servername/;s/ESCAPEDSERVERNAME/$escapedservername/;s/LOGGER/$logger/;s/AA/$aa/" production.yaml > $HOME/.opentox/config/production.yaml
-sed -e "s/PASSWORD/$password/;s/SERVERNAME/$servername/;s/ESCAPEDSERVERNAME/$escapedservername/;s/LOGGER/$logger/;s/AA/$aa/" aa-$install.yaml >> $HOME/.opentox/config/production.yaml
-
-# checkout development version and link lib to opentox-ruby gem
-if [ $branch = "development" ]
-then
- mkdir -p /var/www/opentox
- cd /var/www/opentox
- git clone http://github.com/opentox/opentox-ruby.git
- cd opentox-ruby
- git checkout -t origin/$branch
- gem install jeweler
- rake install
- gem_lib=`gem which opentox-ruby`
- gem_lib=`echo $gem_lib | sed 's/\/opentox-ruby.rb//'`
- mv $gem_lib $gem_lib~
- ln -s /var/www/opentox/opentox-ruby/lib $gem_lib
-fi
-cd $dir
+ aa=""
+fi
+
+mkdir -p "$HOME/.opentox/config" >>$LOG 2>&1
+mkdir -p "$HOME/.opentox/log" >>$LOG 2>&1
+
+$GIT checkout production.yaml >>$LOG 2>&1
+$GIT checkout aa-$OT_INSTALL.yaml >>$LOG 2>&1
+
+cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,\" production.yaml > $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 1"
+cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,\" aa-$OT_INSTALL.yaml >> $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 1"
+
+if [ "$OT_BRANCH" = "development" ] || expr match "$OT_BRANCH" "release"; then
+ mkdir -p $WWW_DEST/opentox >>$LOG 2>&1
+ cd $WWW_DEST/opentox >>$LOG 2>&1
+ rm -rf opentox-ruby >>$LOG 2>&1
+ $GIT clone git://github.com/opentox/opentox-ruby.git >>$LOG 2>&1
+ cd opentox-ruby >>$LOG 2>&1
+ $GIT checkout -b $OT_BRANCH origin/$OT_BRANCH >>$LOG 2>&1
+ cmd="$RAKE install" && run_cmd "$cmd" "Install"
+ GEM_LIB=`$GEM which opentox-ruby | sed 's/\/opentox-ruby.rb//'`
+ rm -rf "$GEM_LIB~" >>$LOG 2>&1
+ mv "$GEM_LIB" "$GEM_LIB~" >>$LOG 2>&1
+ cmd="ln -sf $WWW_DEST/opentox/opentox-ruby/lib $GEM_LIB" && run_cmd "$cmd" "Linking back"
+fi
+
+cd "$DIR"
diff --git a/opentox-webservices.sh b/opentox-webservices.sh
index 294b9bf..91d402e 100644..100755
--- a/opentox-webservices.sh
+++ b/opentox-webservices.sh
@@ -1,24 +1,58 @@
#!/bin/sh
+#
+# Installs Opentox Webservices.
+# Author: Christoph Helma, Andreas Maunz.
+#
-echo "Installing OpenTox webservices"
-. ./config
-# Create opentox system user
-id opentox
-if [ $? -ne 0 ]
-then
- adduser --system opentox
+. "`pwd`/utils.sh"
+DIR=`pwd`
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+WGET="`which wget`"
+if [ ! -e "$WGET" ]; then
+ echo "'wget' missing. Install 'wget' first. Aborting..."
+ exit 1
+fi
+
+RAKE="`which rake`"
+if [ ! -e "$RAKE" ]; then
+ echo "'rake' missing. Install 'rake' first. Aborting..."
+ exit 1
+fi
+
+GIT="`which git`"
+if [ ! -e "$GIT" ]; then
+ echo "'git' missing. Install 'git' first. Aborting..."
+ exit 1
fi
-dir=`pwd`
-mkdir -p /var/www/opentox
-cd /var/www/opentox
-for s in compound dataset algorithm model toxcreate task; do
- git clone git://github.com/opentox/$s.git $s
- cd $s
- git checkout -t origin/$branch
- mkdir -p public
- ln -s /var/www/opentox/$s/public /var/www/$s
- cd -
+LOG="/tmp/`basename $0`-log.txt"
+
+if ! id opentox >>$LOG 2>&1; then
+ cmd="sudo adduser --system opentox" && run_cmd "$cmd" "User 'opentox'"
+fi
+
+echo
+echo "Webservices ('$LOG'):"
+
+mkdir -p "$WWW_DEST/opentox" >>$LOG 2>&1
+cd "$WWW_DEST/opentox" >>$LOG 2>&1
+for s in compound dataset algorithm model toxcreate task validation; do
+ rm -rf "$s" >>$LOG 2>&1
+ $GIT clone "git@github.com:opentox/$s.git" "$s" >>$LOG 2>&1
+ cd "$s" >>$LOG 2>&1
+ $GIT checkout -b $OT_BRANCH origin/$OT_BRANCH >>$LOG 2>&1
+ #rm -rf public >>$LOG 2>&1
+ #mkdir public >>$LOG 2>&1
+ mypath_from="$WWW_DEST/opentox/$s/public"
+ mypath_to="$WWW_DEST/$s"
+ cmd="ln -sf \"$mypath_from\" \"$mypath_to\"" && run_cmd "$cmd" "Linking $s"
+ cd - >>$LOG 2>&1
done
# validation service
@@ -30,10 +64,27 @@ done
#ln -s /var/www/opentox/validation/public /var/www/validation
# fminer etc
-cd /var/www/opentox/algorithm
-updatedb
-rake fminer:install
-chown -R opentox /var/www/opentox
-cp -r $HOME/.opentox /home/opentox/
-chown -R opentox /home/opentox/.opentox
-cd $dir
+cmd="test -f $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config present"
+cd "$WWW_DEST/opentox/algorithm" >>$LOG 2>&1
+cmd="$GIT submodule init" && run_cmd "$cmd" "Fminer Init"
+cmd="$GIT submodule update" && run_cmd "$cmd" "Fminer Update"
+for mylib in bbrc last; do
+ cmd="sed -i 's,^INCLUDE_OB.*,INCLUDE_OB\ =\ -I$OB_DEST/include/openbabel-2.0,g' $WWW_DEST/opentox/algorithm/libfminer/lib$mylib/Makefile; sed -i 's,^LDFLAGS_OB.*,LDFLAGS_OB\ =\ -L$OB_DEST/lib,g' $WWW_DEST/opentox/algorithm/libfminer/lib$mylib/Makefile" && run_cmd "$cmd" "Makefile $mylib (OB)"
+ cmd="sed -i 's,^INCLUDE_RB.*,INCLUDE_RB\ =\ -I$RUBY_DEST/lib/ruby/1.8/`uname -m`-linux,g' $WWW_DEST/opentox/algorithm/libfminer/lib$mylib/Makefile" && run_cmd "$cmd" "Makefile $mylib (RB)"
+done
+cd "libfminer/libbbrc">>$LOG 2>&1
+$GIT checkout master >>$LOG 2>&1
+$GIT pull >>$LOG 2>&1
+cmd="make ruby" && run_cmd "$cmd" "Make BBRC"
+cd ->>$LOG 2>&1
+cd "libfminer/liblast">>$LOG 2>&1
+$GIT checkout master >>$LOG 2>&1
+$GIT pull >>$LOG 2>&1
+cmd="make ruby" && run_cmd "$cmd" "Make LAST"
+cd ->>$LOG 2>&1
+cd "last-utils">>$LOG 2>&1
+$GIT checkout master >>$LOG 2>&1
+$GIT pull >>$LOG 2>&1
+
+cd "$DIR"
+
diff --git a/production.yaml b/production.yaml
index 0e77ddd..f3eee2c 100644
--- a/production.yaml
+++ b/production.yaml
@@ -1,4 +1,4 @@
-:base_dir: /var/www/opentox/
+:base_dir: WWW_DEST
:services:
# make sure to enter a full uri (including training slash)
@@ -8,7 +8,7 @@
opentox-model: "http://SERVERNAME/model/"
opentox-task: "http://SERVERNAME/task/"
opentox-toxcreate: "http://SERVERNAME/toxcreate/"
- opentox-validation: "http://opentox.informatik.uni-freiburg.de/validation/"
+ opentox-validation: "http://SERVERNAME/validation/"
:yaml_hosts:
- "localhost"
diff --git a/redis.sh b/redis.sh
index 830c6c4..2f55539 100644..100755
--- a/redis.sh
+++ b/redis.sh
@@ -1,16 +1,74 @@
#!/bin/sh
+#
+# Installs Redis.
+# Author: Christoph Helma, Andreas Maunz.
+#
-echo "Installing Redis database"
-. /etc/profile
-. ./config
-dir=`pwd`
-cd /tmp
-wget -O - "http://redis.googlecode.com/files/redis-2.2.2.tar.gz" | tar zxv
-cd redis-2.2.2
-make install
-echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
-mkdir -p /opt/redis
-echo "daemonize yes" > /opt/redis/redis.conf
-echo "dir `pwd`" >> /opt/redis/redis.conf
-redis-server /opt/redis/redis.conf
-cd $dir
+. "`pwd`/utils.sh"
+DIR=`pwd`
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+WGET="`which wget`"
+if [ ! -e "$WGET" ]; then
+ echo "'wget' missing. Install 'wget' first. Aborting..."
+ exit 1
+fi
+
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Redis ('$LOG'):"
+
+
+REDIS_DONE=false
+mkdir "$REDIS_DEST" >/dev/null 2>&1
+if [ ! -d "$REDIS_DEST" ]; then
+ echo "Install directory '$REDIS_DEST' is not available! Aborting..."
+ exit 1
+else
+ if ! rmdir "$REDIS_DEST" >/dev/null 2>&1; then # if not empty this will fail
+ REDIS_DONE=true
+ fi
+fi
+
+if ! $REDIS_DONE; then
+ echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf >>$LOG 2>&1
+
+ cd $OT_PREFIX
+ URI="http://redis.googlecode.com/files/redis-$REDIS_VER.tar.gz"
+ if ! [ -d "redis-$REDIS_VER" ]; then
+ cmd="$WGET $URI" && run_cmd "$cmd" "Download"
+ cmd="tar zxf redis-$REDIS_VER.tar.gz" && run_cmd "$cmd" "Unpack"
+ fi
+ cd redis-$REDIS_VER >>$LOG 2>&1
+ cmd="make" && run_cmd "$cmd" "Make"
+
+ if ! grep "daemonize yes" $REDIS_SERVER_CONF >>$LOG 2>&1 ; then
+ echo "daemonize yes" > $REDIS_SERVER_CONF 2>$LOG
+ fi
+
+ if ! grep "dir `pwd`" $REDIS_SERVER_CONF >>$LOG 2>&1 ; then
+ echo "dir `pwd`" >> $REDIS_SERVER_CONF 2>$LOG
+ fi
+
+ if ! grep "save 900 1" $REDIS_SERVER_CONF >>$LOG 2>&1 ; then
+ echo "save 900 1" >> $REDIS_SERVER_CONF 2>$LOG
+ fi
+fi
+
+if [ ! -f $REDIS_CONF ]; then
+ echo "if ! echo \"\$PATH\" | grep \"$REDIS_DEST\">/dev/null 2>&1; then export PATH=$REDIS_DEST/src:\$PATH; fi" >> "$REDIS_CONF"
+ echo "Redis configuration has been stored in '$REDIS_CONF'."
+
+ if ! grep ". \"$REDIS_CONF\"" $OT_UI_CONF; then
+ echo ". \"$REDIS_CONF\"" >> $OT_UI_CONF
+ fi
+
+fi
+
+cd "$DIR"
diff --git a/ruby.sh b/ruby.sh
index 31ea284..a1b8cbe 100644..100755
--- a/ruby.sh
+++ b/ruby.sh
@@ -1,14 +1,83 @@
#!/bin/sh
+#
+# Installs Ruby enterprise edition and passenger gem.
+# A configuration file is created and included in your '$OT_UI_CONF'.
+# Author: Christoph Helma, Andreas Maunz.
+#
-echo "Installing Ruby Enterprise"
-cd /tmp
-wget -O - "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz" | tar zxv
-sh /tmp/ruby-enterprise-1.8.7-2011.03/installer --dont-install-useful-gems --no-dev-docs --auto=/opt/ruby-enterprise-1.8.7-2010.03
-sed -i '/^PATH=.*ruby-enterprise/d' /etc/profile
-echo 'PATH=$PATH:/opt/ruby-enterprise-1.8.7-2010.03/bin' | tee -a /etc/profile
-. /etc/profile
-gem sources -a http://gemcutter.org
-gem sources -r http://rubygems.org/
-echo "gem: --no-ri --no-rdoc" | tee -a ~/.gemrc
-gem install passenger
-cd -
+. "`pwd`/utils.sh"
+DIR="`pwd`"
+
+if [ "$(id -u)" = "0" ]; then
+ echo "This script must be run as non-root." 1>&2
+ exit 1
+fi
+
+# Utils
+WGET="`which wget`"
+if [ ! -e "$WGET" ]; then
+ echo "'wget' missing. Install 'wget' first. Aborting..."
+ exit 1
+fi
+
+# Pkg
+LOG="/tmp/`basename $0`-log.txt"
+
+echo
+echo "Ruby Enterprise edition ('$RUBY_DEST', '$LOG')."
+
+
+mkdir "$RUBY_DEST" >/dev/null 2>&1
+if [ ! -d "$RUBY_DEST" ]; then
+ echo "Install directory '$RUBY_DEST' is not available! Aborting..."
+ exit 1
+else
+ if ! rmdir "$RUBY_DEST" >/dev/null 2>&1; then # if not empty this will fail
+ RUBY_DONE=true
+ fi
+fi
+
+if [ ! $RUBY_DONE ]; then
+ cd /tmp
+ URI="http://rubyenterpriseedition.googlecode.com/files/$RUBY_VER.tar.gz"
+ if ! [ -d "/tmp/$RUBY_VER" ]; then
+ cmd="$WGET $URI" && run_cmd "$cmd" "Download"
+ cmd="tar xzf $RUBY_VER.tar.gz" && run_cmd "$cmd" "Unpack"
+ fi
+ cmd="sh /tmp/$RUBY_VER/installer --dont-install-useful-gems --no-dev-docs --auto=$RUBY_DEST" && run_cmd "$cmd" "Install"
+fi
+
+
+
+if ! [ -f "$RUBY_CONF" ]; then
+ echo "if echo \"\$PATH\" | grep -v \"$RUBY_DEST\">/dev/null 2>&1; then export PATH=\"$RUBY_DEST/bin:\$PATH\"; fi" >> "$RUBY_CONF"
+
+ echo "Ruby configuration has been stored in '$RUBY_CONF'."
+ if ! grep "$RUBY_CONF" $OT_UI_CONF >/dev/null 2>&1 ; then
+ echo ". \"$RUBY_CONF\"" >> $OT_UI_CONF
+ fi
+fi
+. "$RUBY_CONF"
+
+
+GEM="`which gem`"
+if [ ! -e "$GEM" ]; then
+ echo "'gem' missing. Install 'gem' first. Aborting..."
+ exit 1
+fi
+
+if [ "$PASSENGER_SKIP" != "s" ]; then
+ export PATH="$RUBY_DEST/bin:$PATH"
+ cmd="$GEM sources -a http://gemcutter.org" && run_cmd "$cmd" "Add Gemcutter"
+ cmd="$GEM sources -a http://rubygems.org" && run_cmd "$cmd" "Add Rubygems"
+ GEMCONF="gem: --no-ri --no-rdoc"
+ if ! grep "$GEMCONF" $HOME/.gemrc >>$LOG 2>&1; then
+ echo "$GEMCONF" | tee -a $HOME/.gemrc >>$LOG 2>&1
+ fi
+ if ! $GEM list | grep passenger >/dev/null 2>&1; then
+ cmd="$GEM install passenger" && run_cmd "$cmd" "Install Passenger"
+ fi
+
+fi
+
+cd "$DIR"
diff --git a/utils.sh b/utils.sh
new file mode 100755
index 0000000..880028c
--- /dev/null
+++ b/utils.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+check_dest()
+{
+ if ! [ -d "$OT_PREFIX" ]; then
+ if ! mkdir -p "$OT_PREFIX"; then
+ echo "Could not create target directory '$OT_PREFIX'! Aborting..."
+ exit 1
+ fi
+ fi
+}
+
+run_cmd ()
+{
+ local cmd="$1"
+ local title="$2"
+
+ printf "%30s" "'$title'"
+ if ! eval $cmd >>$LOG 2>&1 ; then
+ printf "%50s\n" "FAIL"
+ echo "Last 10 lines of log:"
+ tail -10 "$LOG"
+ exit 1
+ fi
+ printf "%50s\n" "DONE"
+
+}
+
+abs_path()
+{
+ local path="$1"
+ case "$path" in
+ /*) absolute=1 ;;
+ *) absolute=0 ;;
+ esac
+}
+
+. "`pwd`/config.sh"
+touch "$OT_UI_CONF"
+. "$OT_UI_CONF"
+check_dest