commit 54ed6c010f329ff9d343c7e88797989fe7569bb0 Author: tkl Date: Fri Jul 20 14:53:22 2018 +0200 mqtt-logger: Initial commit Signed-off-by: tkl diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f0c3806 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM debian:latest +RUN apt-get update && apt-get install -y python python-pip mosquitto git + +# Install paho-mqtt +RUN yes | pip install paho-mqtt + +# Install paho-mqtt wrapper +RUN git clone https://git.blackfinn.de/python/mqtt.git && \ + cd mqtt && \ + ./setup.py install && \ + cd .. && \ + rm -rf mqtt + +# Install mqtt-logger +RUN git clone https://git.blackfinn.de/python/mqtt_logger.git + +COPY run.sh /bin/ + +ENTRYPOINT ["/bin/run.sh"] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..25289a0 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ + +# mqtt-logger + +## Run + + +```sh +docker run -d -p 1883:1883 -p 8883:8883 -v /srv/mqtt_logger/mqtt:/var/log/mqtt --name mqtt-logger --restart always mqtt-logger +``` + diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..c47c92b --- /dev/null +++ b/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +/etc/init.d/mosquitto start + +sleep 1 + +python /mqtt_logger/mqtt_logger/__init__.py + +# if argument(s) given - execute argument(s) in container. Otherwise loop. +if [ "$#" -gt 0 ]; then + exec $@ +else + while :; + do + sleep 1 + done +fi +