diff --git a/README.md b/README.md index 3324745..8a6be1f 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,18 @@ Examples: File name. When specified, points to a JSON encoded file which contains channel and device address to name mappings (e.g. generated by hm-manager) + + +System start script +------------------- +There is an ```hm2mqtt.service``` file for ```/etc/system.d/system``` directory on a debian or debian like os. +You have to modify the following variables in this file: +- User +- Group +- ExecStart +- WorkingDirectory + +And do not forgett to check the configurations at top of the ```start.sh``` script. See also diff --git a/hm2mqtt.service b/hm2mqtt.service new file mode 100644 index 0000000..c92d154 --- /dev/null +++ b/hm2mqtt.service @@ -0,0 +1,16 @@ +[Unit] +Description=Interface between homematic rfd and mqtt +After=network.target + +[Service] +Type=forking +GuessMainPID=yes +ExecStart=/srv/hm2mqtt/start.sh +ExecStop=/bin/kill -s SIGINT $MAINPID +ExecStopPost= +User=hmcon +Group=hmcon +WorkingDirectory=/srv/hm2mqtt + +[Install] +WantedBy=multi-user.target diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..025595f --- /dev/null +++ b/start.sh @@ -0,0 +1,35 @@ +#!/bin/sh + + +## configurations + +# mqtt server string like "tcp://[IP ADDRSS]:[PORT]" +MQTT_SERVER="tcp://127.0.0.1:1883" + +# homematic server +HM_SERVER="127.0.0.1" + +# java location +JAVA=/usr/bin/java + +# logfile location directory or /dev/null for no logging +currentDate=$(date +%F_%H-%M-%S) +#LOGFILE=/dev/null +LOGFILE="/srv/hm2mqtt/logs/"$currentDate".log" + +# locatin for hm2mqtt.jar file +EXECUTEDIR=/srv/hm2mqtt + +## user configuration ends here + + + +# start hm2mqtt +java \ + -jar $EXECUTEDIR/hm2mqtt.jar \ + hm.host=$HM_SERVER \ + mqtt.server=$MQTT_SERVER \ + > $LOGFILE 2>&1 & + +# exit after starting +exit 0