owntracks recorder

This commit is contained in:
Paolo Asperti 2018-11-21 22:35:56 +01:00
parent bbcdcfe14a
commit 94ce8a80c3
5 changed files with 118 additions and 0 deletions

35
ot-recorder/Dockerfile Normal file
View File

@ -0,0 +1,35 @@
ARG BUILD_FROM
FROM $BUILD_FROM AS builder
ENV LANG C.UTF-8
RUN apk add --no-cache \
abuild linux-headers musl-dev mosquitto-dev \
lmdb-dev curl-dev libconfig-dev gcc make libsodium-dev && \
wget -q https://github.com/owntracks/recorder/archive/0.7.9.tar.gz -O - | tar xvzC /tmp
COPY config.mk /tmp/recorder-0.7.9/
RUN cd /tmp/recorder-0.7.9/ && \
make
ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8
RUN apk -U --no-cache upgrade && \
apk --no-cache add jq && \
apk --no-cache add libcurl lmdb libconfig libsodium mosquitto-libs
VOLUME /owntracks
EXPOSE 8083
COPY --from=builder /tmp/recorder-0.7.9/ocat /usr/sbin/
COPY --from=builder /tmp/recorder-0.7.9/ot-recorder /usr/sbin/
COPY --from=builder /tmp/recorder-0.7.9/docroot /var/spool/owntracks/recorder/htdocs
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]

3
ot-recorder/README.md Normal file
View File

@ -0,0 +1,3 @@
## Owntracks Recorder
[Owntracks Recorder](https://github.com/owntracks/recorder) packaged for hass.io.

31
ot-recorder/config.json Normal file
View File

@ -0,0 +1,31 @@
{
"name": "SNMP",
"url": "https://git.asperti.com/paspo/hassio-addons",
"version": "0.1.0",
"slug": "ot-recorder",
"description": "Owntracks Recorder",
"startup": "before",
"boot": "auto",
"ports": {
"8083": 8083
},
"webui": "http://[HOST]:[PORT:8083]/",
"map": ["share:rw"],
"options": {
"topics": "owntracks/#",
"host": "IPADDRESS_OR_HOSTNAME",
"port": 1883,
"user": "DVES_USER",
"pass": "DVES_PASS",
"qos": 2
},
"schema": {
"topics": "str",
"host": "str",
"port": "port",
"user": "str",
"pass": "str",
"qos": "int"
}
}

21
ot-recorder/config.mk Normal file
View File

@ -0,0 +1,21 @@
FREEBSD ?= no
INSTALLDIR = /usr
WITH_MQTT ?= yes
WITH_HTTP ?= yes
WITH_LUA ?= no
WITH_PING ?= yes
WITH_KILL ?= no
WITH_ENCRYPT ?= yes
WITH_GREENWICH ?= no
STORAGEDEFAULT = /owntracks/
DOCROOT = /var/spool/owntracks/recorder/htdocs
GHASHPREC = 7
JSON_INDENT ?= no
CONFIGFILE = /etc/ot-recorder.cfg
MOSQUITTO_INC = -I/usr/include
MOSQUITTO_LIB = -L/usr/lib
MORELIBS += # -lssl
LUA_CFLAGS = `pkg-config --cflags lua`
LUA_LIBS = `pkg-config --libs lua`
SODIUM_CFLAGS = `pkg-config --cflags libsodium`
SODIUM_LIBS = `pkg-config --libs libsodium`

28
ot-recorder/run.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/sh
set -e
CONFIG_PATH=/data/options.json
TOPICS=$(jq --raw-output ".topics" $CONFIG_PATH)
HOST=$(jq --raw-output ".host" $CONFIG_PATH)
PORT=$(jq --raw-output ".port" $CONFIG_PATH)
USER=$(jq --raw-output ".user" $CONFIG_PATH)
PASS=$(jq --raw-output ".pass" $CONFIG_PATH)
QOS=$(jq --raw-output ".qos" $CONFIG_PATH)
echo "
OTR_STORAGEDIR = \"/owntracks\"
OTR_TOPICS = \"$TOPICS\"
OTR_HOST = \"$HOST\"
OTR_PORT = $PORT
OTR_USER = \"$USER\"
OTR_PASS = \"$PASS\"
OTR_QOS = $QOS
" > /etc/ot-recorder.cfg
if [ ! -f /owntracks/ghash/data.mdb ] ; then
/usr/sbin/ot-recorder --initialize
fi
/usr/sbin/ot-recorder --http-host 0.0.0.0