services: Add irc-doorduino
This commit is contained in:
parent
7eea8662da
commit
0e75ce25c5
4 changed files with 71 additions and 0 deletions
|
@ -13,6 +13,12 @@
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: restart irc-doorduino
|
||||||
|
systemd:
|
||||||
|
name: irc-doorduino
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
- name: restart discord-bot
|
- name: restart discord-bot
|
||||||
systemd:
|
systemd:
|
||||||
name: discord-bot
|
name: discord-bot
|
||||||
|
|
|
@ -58,3 +58,28 @@
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Install doorduino notification
|
||||||
|
template:
|
||||||
|
src: irc-doorduino.sh
|
||||||
|
dest: /var/lib/irc-helpers/doorduino.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
notify: restart irc-doorduino
|
||||||
|
|
||||||
|
- name: Install doorduino notification service
|
||||||
|
template:
|
||||||
|
src: irc-doorduino.service
|
||||||
|
dest: /etc/systemd/system/irc-doorduino.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart irc-doorduino
|
||||||
|
|
||||||
|
- name: Start irc-doorduino
|
||||||
|
systemd:
|
||||||
|
name: irc-doorduino
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: true
|
||||||
|
|
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
Reference in a new issue