aboutsummaryrefslogtreecommitdiffstats
path: root/osdfapp.sh
blob: 3dc4679c54403192d34c6a436aa372e250a49c18 (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
78
79
80
81
#!/bin/bash

# -------------------------------------------------------------------------
#   Copyright (c) 2015-2017 AT&T Intellectual Property
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
# -------------------------------------------------------------------------
#

usage() {
	echo "Usage:"
	echo "    $0 -h Display this help message."
	echo "    $0 -c configfile_path(optional) -x app.py file"
	exit 0
}

cd $(dirname $0)

# bash ../etc/make-certs.sh  # create the https certificates if they are not present

while getopts ":hc:x:" opt; do
  case ${opt} in
    h )
      usage
      ;;
    c )
      # process option configuration
      export OSDF_CONFIG_FILE=$OPTARG
      ;;
    x )
      # process executable file
      export EXEC_FILE=$OPTARG
      ;;
    ? )
      usage
      ;;
    : )
      echo "Invalid Option: -$OPTARG requires an argument" 1>&2
      exit 1
     ;;
  esac
done
shift $(( OPTIND - 1 ))

set -e

LOGS=logs
mkdir -p $LOGS

if [ -e /opt/app/ssl_cert/aaf_root_ca.cer ]; then
    #assuming that this would be an ubuntu vm.
    cp /opt/app/ssl_cert/aaf_root_ca.cer /usr/local/share/ca-certificates/aafcacert.crt
    chmod 444 /usr/local/share/ca-certificates/aafcacert.crt
    update-ca-certificates
fi

if [ -e /etc/ssl/certs/aafcacert.pem ]; then
    export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
else
    export REQUESTS_CA_BUNDLE=/opt/app/ssl_cert/aaf_root_ca.cer
fi

if [ ! -z "$EXEC_FILE" ]
then
	# flask run
	echo "Running $EXEC_FILE"
	python $EXEC_FILE # running the app
else
    usage
fi