summaryrefslogtreecommitdiff
path: root/environment_update.sh
blob: d0beae43baf8ca1eb2f78910a4ac1df523b8dbc3 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
# Update script for OpenTox-ruby and webservices
# Authors: Andreas Maunz, David Vorgrimmler
# This script updates a productiv version of IST Opentox Services. All data will be saved and recovered.
# Make sure your web services are down befor running this script.
# You may modify some variables e.g. HOME, OTPREFIX, BACKUP_DIR.
# opentox/install is needed and has to be configured

HOME="/home/opentox"
. $HOME/.opentox-ui.sh

OTPREFIX="$HOME/opentox"
BACKUP_DIR="$OTPREFIX/ot-server-backup"
mkdir $BACKUP_DIR >/dev/null 2>&1
mkdir -p $BACKUP_DIR/tmp/dataset/public >/dev/null 2>&1
mkdir -p $BACKUP_DIR/tmp/model/public >/dev/null 2>&1
mkdir -p $BACKUP_DIR/tmp/validation >/dev/null 2>&1
#mkdir -p $BACKUP_DIR/tmp/log >/dev/null 2>&1


echo "Creating backup of www..."
TAR_NAME=$BACKUP_DIR/"www_`date +%y%m%d`.tar.gz"

if [ -e $TAR_NAME ] || tar czvf $TAR_NAME "$OTPREFIX/opentox-ruby/www"; then
  echo
  echo "Will delete www in 10s! Press Ctrl+C to abort..."
  sleep 10
  sudo rm -rf "$OTPREFIX/opentox-ruby/www"
fi


NGINX="`which nginx`"
RAKE="`which rake`"

if ! [ -e "$RAKE" ]; then
  echo "Rake not found."
  exit 1
fi
if ! [ -e "$NGINX" ]; then
  echo "Nginx not found."
  exit 1
fi
if ! cd "$OTPREFIX/install"; then
  echo "$OTPREFIX/install dir not found"
fi


OTINSTALL="$OTPREFIX/install/opentox-webservices.sh"
if ! [ -e "$OTINSTALL" ]; then
  echo "$OTINSTALL not found."
  exit 1
fi
chmod +x $OTINSTALL
`$OTINSTALL`
echo "$OTINSTALL script end."


OTRUBYINSTALL="$OTPREFIX/install/opentox-ruby.sh"
if ! [ -e "$OTRUBYINSTALL" ]; then
  echo "$OTRUBYINSTALL not found."
  exit 1
fi
chmod +x $OTRUBYINSTALL
`$OTRUBYINSTALL`
echo "$OTRUBYINSTALL script end."


echo "Extracting backup of www..."
cd /
DEST_DATASET=`echo "$OTPREFIX/opentox-ruby/www/opentox/dataset/public/*yaml" | sed 's/.\(.*\)/\1/'`
DEST_MODEL=`echo "$OTPREFIX/opentox-ruby/www/opentox/model/public/*yaml" | sed 's/.\(.*\)/\1/'`
DEST_REPORTS=`echo "$OTPREFIX/opentox-ruby/www/opentox/validation/reports" | sed 's/.\(.*\)/\1/'`
tar xzvf $TAR_NAME --wildcards $DEST_DATASET
tar xzvf $TAR_NAME --wildcards $DEST_MODEL
tar xzvf $TAR_NAME $DEST_REPORTS
cd -
echo "End of script."