summaryrefslogtreecommitdiff
path: root/bin/compound-install
blob: 9b1921083400606af359e6509abd47305a4ebd74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/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

# Adjust ruby version here!
RUBY_NUM_VER="1.9.3-p194"

echo
echo "Welcome to service installation (<Return> to continue)."
read delete_me


# 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"
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"

# ruby
install_ruby

# 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 '$compound = { :uri => "http://localhost:8082/compound" }' >> $OT_DEFAULT_CONF; fi

notify

# return to wd
cd "$DIR"