oyooyo / keyble

Command line tools and library for controlling eqiva eQ-3 Bluetooth smart locks
92 stars 29 forks source link

Systemd Start Script for Mosquitto connection #6

Closed henfri closed 3 years ago

henfri commented 6 years ago

Hello,

would it make sense to document howto autostart the chain of mosquitto commands and keyble? Here my conf:

/etc/systemd/system/SmartlockSchuppen.service
[Unit]
Description=SmartlockHintertuer
Require = network-online.target
After = network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/SmartlockSchuppen.sh
Restart=always

[Install]
WantedBy=multi-user.target

/usr/local/bin/SmartlockSchuppen.sh then just includes the commands `#!/bin/bash

/usr/bin/mosquitto_sub -h 192.168.177.3 -t "SmartlockHintertuer/action" | /usr/local/bin/keyble-sendcommand --address x --user_id 3 --user_key y | /usr/bin/mosquitto_pub -h 192.168.177.3 -l -r -t "SmartlockHintertuer/status"

`

Seems trivial, but took me a while to figure out. With an init-script it did not work. The network was not reachable -although I had it as a dependency. My first tries with systemd failed as well until I put the chain of commands into an external script. So, it is not so trivial in the end

Greetings, Hendrik

oyooyo commented 6 years ago

Hi Hendrik, Very good idea! Since you already did all the work, could you please create a pull request as well?