services: Add irc-doorduino
This commit is contained in:
parent
7eea8662da
commit
0e75ce25c5
4 changed files with 71 additions and 0 deletions
16
roles/services/templates/irc-doorduino.service
Normal file
16
roles/services/templates/irc-doorduino.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Managed by Ansible
|
||||
|
||||
[Unit]
|
||||
Description=Bitlair IRC doorduino notification
|
||||
After=network.target
|
||||
Requires=irc-bot.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/bash /var/lib/irc-helpers/doorduino.sh
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
DynamicUser=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
24
roles/services/templates/irc-doorduino.sh
Normal file
24
roles/services/templates/irc-doorduino.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Managed by Ansible
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
initial=1
|
||||
|
||||
mqtt-simple -h {{ mqtt_internal_host }} -t "bitlair/doorduino/+" |
|
||||
while read line; do
|
||||
topic=$(echo "$line" | cut -d' ' -f1 | sed "s/bitlair\/doorduino\///")
|
||||
value=$(echo "$line" | cut -s -d' ' -f2-)
|
||||
|
||||
if [ $initial == 0 ] && [ $value != 0 ]; then
|
||||
if [ $topic == "doorbell" ]; then
|
||||
irc-say "DEURBEL! Open de deur beneden!"
|
||||
elif [ $topic != "dooropen" ]; then
|
||||
irc-say "Doorduino: $topic $value"
|
||||
fi
|
||||
fi
|
||||
initial=0
|
||||
done
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue