forked from certik/femhub-online-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spkg-install
executable file
·41 lines (34 loc) · 1.26 KB
/
spkg-install
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
#! /bin/sh
set -e
if [ "$SPKG_LOCAL" = "" ]; then
echo "SPKG_LOCAL undefined ... exiting";
exit 1
fi
PACKAGE_NAME=onlinelab
CONFIG_DIR="$SPKG_LOCAL/share/onlinelab/"
# remove old install:
rm -rf $SPKG_LOCAL/lib/python/site-packages/onlinelab
CONFIG_DIR_BACKUP=`mktemp -d --tmpdir=$SPKG_LOCAL/share/`
mkdir -p $CONFIG_DIR
mv $CONFIG_DIR $CONFIG_DIR_BACKUP/
echo "Old data are stored in: $CONFIG_DIR_BACKUP"
# install online lab
cp -pr onlinelab $SPKG_LOCAL/lib/python/site-packages/
cp bin/onlinelab $SPKG_LOCAL/bin
mkdir -p $CONFIG_DIR
cp -r ui $CONFIG_DIR/
# init the online lab
CUR=`pwd`
cd $SPKG_LOCAL #to make sure the right lab gets imported
onlinelab core init --home=$CONFIG_DIR/core-home --ui-path=$CONFIG_DIR/ui
onlinelab service init --home=$CONFIG_DIR/service-home
# allow to pass the os.environ into the engine Python process (so that
# LD_LIBRARY_PATH and other things are properly set):
echo "ENVIRON = True" >> $CONFIG_DIR/service-home/settings.py
# Try to copy the data from the old installation:
if [ -f "$CONFIG_DIR_BACKUP/onlinelab/core-home/onlinelab.db" ]; then
echo "Copying old database into the new lab"
cp "$CONFIG_DIR_BACKUP/onlinelab/core-home/onlinelab.db" $CONFIG_DIR/core-home/
else
echo "No old database found, nothing copied."
fi