Initial commit
[ta/distributed-state-server.git] / src / dss / tst / start-server.sh
1 #! /bin/bash
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17
18 cwd=$(pwd)
19
20 if [ $# -ne 1 ]; then
21     echo "Usage: $0 <work-dir>"
22 fi
23
24 workdir=$1
25
26 echo "Creating work dir $workdir"
27 mkdir $workdir
28 if [ $? -ne 0 ]; then
29     exit 1
30 fi
31
32 echo "Copying dss-server-config.ini file"
33 cp $cwd/dss-server-config.ini $workdir/
34 if [ $? -ne 0 ]; then
35     exit 1
36 fi
37
38 echo "Copying plugin.ini file"
39 cp $cwd/plugin.ini $workdir/
40 if [ $? -ne 0 ]; then
41     exit 1
42 fi
43
44 echo "Copying plugin"
45 cp ../../../../plugins/dssfile.py $workdir/
46
47 echo "Updating dss-server-config.ini"
48 pluginfile=$workdir/dssfile.py
49 escapepluginfile=$(echo $pluginfile | sed 's/\//\\\//g')
50 sed -i "s/PLUGIN_FILE/$escapepluginfile/g" $workdir/dss-server-config.ini
51 if [ $? -ne 0 ]; then
52     exit 1
53 fi
54
55 echo "Updating plugin.ini"
56 pluginconf=$workdir/plugin.ini
57 escapepluginconf=$(echo $pluginconf | sed 's/\//\\\//g')
58 sed -i "s/PLUGIN_CONF/$escapepluginconf/g" $workdir/dss-server-config.ini
59
60 files=$workdir/files
61 escapefiles=$(echo $files | sed 's/\//\\\//g')
62 mkdir $files
63 if [ $? -ne 0 ]; then
64     exit 1
65 fi
66
67 sed -i "s/DIR/$escapefiles/g" $workdir/plugin.ini
68
69
70
71 export PYTHONPATH=$cwd/../../../
72
73 exec python $cwd/../server/dss_main.py --config $workdir/dss-server-config.ini