Fixing OSS license issues - 2
[osm/UI.git] / skyquake / plugins / composer / scripts / launch_composer.sh
1 #!/bin/bash
2
3 #
4 # Copyright 2016 RIFT.IO Inc
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18
19 usage() {
20 echo "usage: launch_ui.sh [--enable-https --keyfile-path=<keyfile_path> --certfile-path=<certfile-path>]"
21 }
22
23 start_servers() {
24 cd $THIS_DIR
25 echo "Killing any previous instance of server_composer_ui.py"
26 ps -ef | awk '/[s]cripts\/server_composer_ui.py/{print $2}' | xargs kill -9
27
28 echo "Running Python webserver. HTTPS Enabled: ${ENABLE_HTTPS}"
29 cd ../dist
30 if [ ! -z "${ENABLE_HTTPS}" ]; then
31 ../scripts/server_composer_ui.py --enable-https --keyfile-path="${KEYFILE_PATH}" --certfile-path="${CERTFILE_PATH}"&
32 else
33 ../scripts/server_composer_ui.py
34 fi
35 }
36
37 # Begin work
38 for i in "$@"
39 do
40 case $i in
41 -k=*|--keyfile-path=*)
42 KEYFILE_PATH="${i#*=}"
43 shift # past argument=value
44 ;;
45 -c=*|--certfile-path=*)
46 CERTFILE_PATH="${i#*=}"
47 shift # past argument=value
48 ;;
49 -h|--help)
50 usage
51 exit
52 ;;
53 -e|--enable-https)
54 ENABLE_HTTPS=YES
55 shift # past argument=value
56 ;;
57 *)
58 # unknown option
59 ;;
60 esac
61 done
62
63 if [[ ! -z "${ENABLE_HTTPS}" ]]; then
64 if [ -z "${KEYFILE_PATH}" ] || [ -z "{CERTFILE_PATH}" ]; then
65 usage
66 exit
67 fi
68 fi
69
70 # change to the directory of this script
71 THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
72
73 # Call function to start web and API servers
74 start_servers
75
76 while true; do
77 sleep 5
78 done