services: Add flipdot
This commit is contained in:
parent
cdc9f519f0
commit
2d22a6e769
7 changed files with 84 additions and 0 deletions
2
roles/services/defaults/main.yaml
Normal file
2
roles/services/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
flipdot_host: 100.64.0.90
|
||||||
|
flipdot_powebar_num: 3
|
|
@ -7,6 +7,12 @@
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: restart flipdot
|
||||||
|
systemd:
|
||||||
|
name: flipdot
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
- name: restart siahsd
|
- name: restart siahsd
|
||||||
systemd:
|
systemd:
|
||||||
name: siahsd
|
name: siahsd
|
||||||
|
|
28
roles/services/tasks/flipdot.yaml
Normal file
28
roles/services/tasks/flipdot.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: Install flipdot scripts
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: "/usr/local/bin/{{ item }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
notify: restart flipdot
|
||||||
|
with_items:
|
||||||
|
- flipdot-reboot.sh
|
||||||
|
- flipdot-time.sh
|
||||||
|
|
||||||
|
- name: Install flipdot service
|
||||||
|
template:
|
||||||
|
src: flipdot.service
|
||||||
|
dest: /etc/systemd/system/flipdot.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart flipdot
|
||||||
|
|
||||||
|
- name: Start flipdot
|
||||||
|
systemd:
|
||||||
|
name: flipdot
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: true
|
|
@ -1,4 +1,7 @@
|
||||||
---
|
---
|
||||||
|
- tags: services_flipdot
|
||||||
|
import_tasks: flipdot.yaml
|
||||||
|
|
||||||
- tags: services_siahsd
|
- tags: services_siahsd
|
||||||
import_tasks: siahsd.yaml
|
import_tasks: siahsd.yaml
|
||||||
|
|
||||||
|
|
4
roles/services/templates/flipdot-reboot.sh
Normal file
4
roles/services/templates/flipdot-reboot.sh
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
powerbar-switch {{ flipdot_powebar_num }} off
|
||||||
|
powerbar-switch {{ flipdot_powebar_num }} on
|
25
roles/services/templates/flipdot-time.sh
Normal file
25
roles/services/templates/flipdot-time.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
HOST={{ flipdot_host }}
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
time=`date +%H:%M`
|
||||||
|
tmp=/tmp/flipdot.gray
|
||||||
|
|
||||||
|
convert -size 336x16 xc:black -density 800x240 -font Liberation-Mono -pointsize 6 -fill white -gravity Center -annotate +0+1 `date +%H:%M` -draw "line 0,15,$(((`date +1%S`-100)*56/10)),15" -depth 8 $tmp
|
||||||
|
(echo -ne "\x00\x00\x15\x00" ; dd if=$tmp bs=5376 count=1 2>/dev/null) | nc -q1 -w1 $HOST 7890
|
||||||
|
sleep 1
|
||||||
|
convert -size 336x16 xc:black -density 800x240 -font Liberation-Mono -pointsize 6 -fill white -gravity Center -annotate +0+1 "`date "+%H %M"`" -draw "line 0,15,$(((`date +1%S`-100)*56/10)),15" -depth 8 $tmp
|
||||||
|
(echo -ne "\x00\x00\x15\x00" ; dd if=$tmp bs=5376 count=1 2>/dev/null) | nc -q1 -w1 $HOST 7890
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if [ $time != `date +%H:%M` ]
|
||||||
|
then
|
||||||
|
convert -size 336x16 xc:white -density 800x240 -font Liberation-Mono -pointsize 6 -fill black -gravity Center -annotate +0+1 `date +%H:%M` -depth 8 $tmp; (echo -ne "\x00\x00\x15\x00" ; dd if=$tmp bs=5376 count=1 2>/dev/null) | nc -q1 -w1 $HOST 7890
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
done
|
16
roles/services/templates/flipdot.service
Normal file
16
roles/services/templates/flipdot.service
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Managed by Ansible
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Big flipdot display
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/local/bin/flipdot-time.sh
|
||||||
|
ExecStopPost=/usr/local/bin/flipdot-reboot.sh
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=30s
|
||||||
|
DynamicUser=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Add table
Reference in a new issue