#!/bin/sh # Installs Opentox Webservice. # Author: Christoph Helma, Andreas Maunz. SELF=$(basename $0 -install) [ "`id -u`" = "0" ] && echo "This script must be run as non-root." 1>&2 && exit 1 SILENT=false if [ -n "$1" ] then if [ "$1" = "silent" ] then SILENT=true fi fi if [ $SILENT = false ]; then echo echo "Welcome to service installation ( to continue)." read delete_me fi # check wd is root of service DIR=`pwd` if echo $DIR | grep "$SELF/bin" >/dev/null 2>&1 ; then cd ..; fi # # # Boot the script # load base config, helper funs, environment OT_CONFIG_DIR="$HOME/.opentox" ! [ -f "$OT_CONFIG_DIR/config/install/config.sh" ] && echo "config.sh not found." 1>&2 && exit 1 || . $OT_CONFIG_DIR/config/install/config.sh ! [ -f "$OT_PREFIX/install/utils.sh" ] && echo "utils.sh not found." 1>&2 && exit 1 || . $OT_PREFIX/install/utils.sh [ -f $OT_CONFIG_DIR/opentox-ui.sh ] && . $OT_CONFIG_DIR/opentox-ui.sh # should have been done by user already RUBY_DIR="$HOME/.rbenv/versions/$RUBY_NUM_VER" # # # Install check_utils "rbenv find R javac" check_log $SELF if [ "$OT_BRANCH" = "development" ]; then cmd="test -d $OT_PREFIX/opentox-server" && run_cmd "$cmd" "Opentox-server" cmd="test -d $OT_PREFIX/opentox-client" && run_cmd "$cmd" "Opentox-client" fi # log directory for this service [ -d $OT_CONFIG_DIR/config/$SELF ] || cmd="mkdir -p $OT_CONFIG_DIR/config/$SELF" && run_cmd "$cmd" "Config directory" echo cd $DIR/../java cmd="$JAVAC -classpath classes:* *.java 2>&1" && run_cmd "$cmd" "Compile Algorithm java classes" cd $DIR/.. sed -i "1irequire 'openbabel'" application.rb # Adjust ruby version here! RUBY_NUM_VER="2.0.0-p481" # ruby install_ruby # fminer ( [ -n "`$FIND libfminer/ -name bbrc.so 2>/dev/null`" ] && [ -n "`$FIND libfminer/ -name last.so 2>/dev/null`" ] ) || . ./bin/fminer-install # R R_DONE=false mkdir "$R_DEST" >/dev/null 2>&1 if [ ! -d "$R_DEST" ]; then echo "Install directory '$R_DEST' is not available! Aborting..." exit 1 else if ! rmdir "$R_DEST" >/dev/null 2>&1; then # if not empty this will fail R_DONE=true else mkdir "$R_DEST" >/dev/null 2>&1 fi fi if ! $R_DONE; then export R_LIBS="$R_DEST" # To install non-global export CRAN_MIRROR="$R_MIRROR" # To install non-global cmd="$R CMD BATCH bin/packs.R" && run_cmd "$cmd" "R packages" fi # self echo install_with_bundler # config [ -f $OT_CONFIG_DIR/config/$SELF.rb ] || touch $OT_CONFIG_DIR/config/$SELF.rb if ! cat "$OT_CONFIG_DIR/config/$SELF.rb" | grep "four_store">/dev/null 2>&1; then echo '$four_store = { :uri => "http://localhost:9088", :user => "", :password => "" }' >> $OT_CONFIG_DIR/config/$SELF.rb; fi if ! cat "$OT_CONFIG_DIR/config/$SELF.rb" | grep "aa">/dev/null 2>&1; then echo '$aa = { :uri => nil }' >> $OT_CONFIG_DIR/config/$SELF.rb; fi if ! cat "$OT_DEFAULT_CONF" | grep "$SELF">/dev/null 2>&1; then echo '$algorithm = { :uri => "http://localhost:8081/algorithm" }' >> $OT_DEFAULT_CONF; fi if [ ! -f $R_CONF ]; then echo "if echo \"\$R_LIBS\" | grep -v \"$R_DEST\">/dev/null 2>&1; then export R_LIBS=\"$R_DEST\"; fi" >> "$R_CONF" echo "if ! [ -d \"$R_DEST\" ]; then echo \"\$0: '$R_DEST' is not a directory!\"; fi" >> "$R_CONF" echo "R package destination stored in '$R_CONF'." if ! grep "$R_CONF" $OT_UI_CONF >/dev/null 2>&1 ; then echo ". \"$R_CONF\"" >> $OT_UI_CONF fi fi if [ $SILENT = false ]; then notify fi # return to wd cd "$DIR"