OpenMTC/apps/OrionContextBroker/docker/configure-orioncontextbroker-and-start

64 lines
1.8 KiB
Plaintext
Raw Normal View History

2017-11-07 13:41:38 +00:00
#!/usr/bin/env bash
CONFIG_FILE="/etc/openmtc/orioncontextbroker/config.json"
NAME=${NAME-"OrionContextBroker"}
2018-01-10 14:02:55 +00:00
EP=${EP-"http://localhost:18000"}
2017-11-07 13:41:38 +00:00
CSE_BASE=${CSE_BASE-"onem2m"}
POAS=${POAS-'["http://auto:25396"]'}
2018-01-10 14:02:55 +00:00
ORIGINATOR_PRE=${ORIGINATOR_PRE-"//openmtc.org/in-cse-1"}
2017-11-07 13:41:38 +00:00
SSL_CRT=${SSL_CRT-"/etc/openmtc/certs/orioncontextbroker.cert.pem"}
SSL_KEY=${SSL_KEY-"/etc/openmtc/certs/orioncontextbroker.key.pem"}
SSL_CA=${SSL_CA-"/etc/openmtc/certs/ca-chain.cert.pem"}
ORION_HOST=${ORION_HOST-"http://localhost:1026"}
ORION_API=${ORION_API-"v2"}
2018-02-21 14:08:58 +00:00
ACCUMULATE_ADDRESS=${ACCUMULATE_ADDRESS-"http://localhost:8080"}
2017-11-07 13:41:38 +00:00
# defaults logging
LOGGING_FILE=${LOGGING_FILE-"/var/log/openmtc/orioncontextbroker.log"}
LOGGING_LEVEL=${LOGGING_LEVEL-"ERROR"}
# ensure correct level
case ${LOGGING_LEVEL} in
FATAL|ERROR|WARN|INFO|DEBUG)
;;
*)
LOGGING_LEVEL="ERROR"
;;
esac
# local ip
LOCAL_IP=$(ip r get 8.8.8.8 | awk 'NR==1 {print $NF}')
# set hostname
HOST_NAME=${EXTERNAL_IP-${LOCAL_IP}}
# Configuration of the service.
CONFIG_TEMP=${CONFIG_FILE}".tmp"
echo -n "Configuring M2M orioncontextbroker..."
JQ_STRING='.'
# basics
JQ_STRING=${JQ_STRING}' |
.name = "'${NAME}'" |
.ep = "'${EP}'" |
.cse_base = "'${CSE_BASE}'" |
.poas = '${POAS}' |
.originator_pre = "'${ORIGINATOR_PRE}'" |
.orion_host = "'${ORION_HOST}'" |
.orion_api = "'${ORION_API}'" |
2018-02-21 14:08:58 +00:00
.accumulate_address = "'${ACCUMULATE_ADDRESS}'" |
2017-11-07 13:41:38 +00:00
.ssl_certs.cert_file = "'${SSL_CRT}'" |
.ssl_certs.key_file = "'${SSL_KEY}'" |
.ssl_certs.ca_certs = "'${SSL_CA}'" |
.logging.file |= "'${LOGGING_FILE}'" |
.logging.level |= "'${LOGGING_LEVEL}'"
'
cat ${CONFIG_FILE} | jq -M "${JQ_STRING}"> ${CONFIG_TEMP}
mv ${CONFIG_TEMP} ${CONFIG_FILE}
echo "done"
exec python -m orioncontextbroker $@