Commit 0b048ec0 authored by Laurent Velez's avatar Laurent Velez
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+47 −0
Original line number Diff line number Diff line

.idea

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyBuilder
target/

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Custom
#/openmtc*

Device_AE/MANIFEST.in

0 → 100644
+1 −0
Original line number Diff line number Diff line
include utils.py
+3 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

exec python3 -m device_ae $@

Device_AE/config.json

0 → 100644
+18 −0
Original line number Diff line number Diff line
{
  "name": "Device_AE",
  "ep": "http://gateway:8000",
  "cse_base": "onem2m",
  "poas": [
    "http://device:28013"
  ],
  "originator_pre": "//openmtc.org/mn-cse-1",
  "ssl_certs": {
    "cert_file": null,
    "key_file": null,
    "ca_certs": null
  },
  "logging": {
    "level": "INFO",
    "file": "./log/device_ae.log"
  }
}
+57 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

CONFIG_FILE="/etc/openmtc/device_ae/config.json"

NAME=${NAME-"Device_AE"}
EP=${EP-"http://gateway:8000"}
CSE_BASE=${CSE_BASE-"onem2m"}
POAS=${POAS-'["http://auto:28013"]'}
ORIGINATOR_PRE=${ORIGINATOR_PRE-"//openmtc.org/mn-cse-1"}
SSL_CRT=${SSL_CRT-"/etc/openmtc/certs/device_ae.cert.pem"}
SSL_KEY=${SSL_KEY-"/etc/openmtc/certs/device_ae.key.pem"}
SSL_CA=${SSL_CA-"/etc/openmtc/certs/ca-chain.cert.pem"}

# defaults logging
LOGGING_FILE=${LOGGING_FILE-"/var/log/openmtc/device_ae.log"}
LOGGING_LEVEL=${LOGGING_LEVEL-"DEBUG"}

# ensure correct level
case ${LOGGING_LEVEL} in
    FATAL|ERROR|WARN|INFO|DEBUG)
    ;;
    *)
    LOGGING_LEVEL="DEBUG"
    ;;
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 device_ae..."
JQ_STRING='.'

# basics
JQ_STRING=${JQ_STRING}' |
    .name = "'${NAME}'" |
    .ep = "'${EP}'" |
    .cse_base = "'${CSE_BASE}'" |
    .poas = '${POAS}' |
    .originator_pre = "'${ORIGINATOR_PRE}'" |
    .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 python3 -m device_ae $@