Add scripts for Bitlair and DJO

This commit is contained in:
polyfloyd 2016-10-02 20:01:59 +02:00
parent 5b96a6be43
commit 239e6cec0e
27 changed files with 105 additions and 1 deletions

3
bitlair_closed.d/10_log Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "Space closed on $(date)" >> /var/log/spacestate.log

3
bitlair_closed.d/10_mqtt Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state' -m 'closed'

View file

@ -0,0 +1,7 @@
#!/bin/bash
# Switches off the led-board.
ssh root@bitpanel.bitlair.nl shutdown -h now
sleep 5
apc-switch 23 off
sleep 1

View file

@ -0,0 +1,11 @@
#!/bin/bash
ssh -o ConnectTimeout=1 root@music.bitlair.nl shutdown -h now
sleep 5
apc-switch 13 2
# Amplifier and KVM switch
apc-switch 20 2
sleep 1
mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/music/space/state' -m 'stopped'

7
bitlair_closed.d/20_phone_off Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# Switches off the phones.
poe-switch 1 2
sleep 1
poe-switch 2 2
sleep 1

View file

@ -0,0 +1,3 @@
#!/bin/bash
ssh -o ConnectTimeout=1 root@statsbak.bitlair.nl shutdown -h now

3
bitlair_closed.d/80_irc Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
irc-say "Bitlair is now closed"

View file

@ -0,0 +1,3 @@
#!/bin/bash
bitlair-tweet "We are closed."

3
bitlair_open.d/10_log Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "Space opened on $(date)" >> /var/log/spacestate.log

3
bitlair_open.d/10_mqtt Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state' -m 'open'

View file

@ -0,0 +1,6 @@
#!/bin/bash
# Switches on the led-board.
apc-switch 23 on
sleep 1

11
bitlair_open.d/20_music_poweron Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
# Switches on the music computer.
apc-switch 13 off
sleep 5
apc-switch 13 on
sleep 1
# Amplifier and KVM switch
apc-switch 20 on
sleep 1

7
bitlair_open.d/20_phone_on Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# Switches on the phones.
poe-switch 1 1
sleep 1
poe-switch 2 1
sleep 1

View file

@ -0,0 +1,8 @@
#!/bin/bash
# Starts the computer displaying pretty graphs.
for i in {0..3}; do
wakeonlan '00:1e:c9:72:21:c4'
sleep 1
done

3
bitlair_open.d/80_irc Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
irc-say "Bitlair is now open!"

View file

@ -0,0 +1,3 @@
#!/bin/bash
bitlair-tweet "We are OPEN!"

3
djo_closed.d/10_mqtt Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state/djo' -m 'closed'

View file

@ -0,0 +1 @@
../bitlair_closed.d/20_ledboard_poweroff

View file

@ -0,0 +1 @@
../bitlair_closed.d/20_music_poweroff

View file

@ -0,0 +1 @@
../bitlair_closed.d/20_statsdisplay_poweroff

3
djo_closed.d/80_irc Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "DJO is now open" | nc 127.0.0.1 31337

3
djo_open.d/10_mqtt Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state/djo' -m 'open'

View file

@ -0,0 +1 @@
../bitlair_open.d/20_ledboard_poweron

1
djo_open.d/20_music_poweron Symbolic link
View file

@ -0,0 +1 @@
../bitlair_open.d/20_music_poweron

View file

@ -0,0 +1 @@
../bitlair_open.d/20_statsdisplay_poweron

3
djo_open.d/80_irc Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "DJO is now open" | nc 127.0.0.1 31337

View file

@ -38,7 +38,9 @@ def set_bit(name, bit):
def alarm_disarmed():
return mqtt_get('bitlair/alarm', 'armed').split(' ')[0] == 'disarmed'
with open('/tmp/alarmdisarmed', 'r') as f:
return f.read() == '1'
# return mqtt_get('bitlair/alarm', 'armed').split(' ')[0] == 'disarmed'
def in_djo_time():
times = [