Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start scripts for debain systems #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions hm2mqtt.service
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -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