diff --git a/bitlair_closed.d/10_log b/bitlair_closed.d/10_log new file mode 100755 index 0000000..58011e2 --- /dev/null +++ b/bitlair_closed.d/10_log @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Space closed on $(date)" >> /var/log/spacestate.log diff --git a/bitlair_closed.d/10_mqtt b/bitlair_closed.d/10_mqtt new file mode 100755 index 0000000..88092d6 --- /dev/null +++ b/bitlair_closed.d/10_mqtt @@ -0,0 +1,3 @@ +#!/bin/bash + +mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state' -m 'closed' diff --git a/bitlair_closed.d/20_ledboard_poweroff b/bitlair_closed.d/20_ledboard_poweroff new file mode 100755 index 0000000..308af0a --- /dev/null +++ b/bitlair_closed.d/20_ledboard_poweroff @@ -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 diff --git a/bitlair_closed.d/20_music_poweroff b/bitlair_closed.d/20_music_poweroff new file mode 100755 index 0000000..5abb958 --- /dev/null +++ b/bitlair_closed.d/20_music_poweroff @@ -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' diff --git a/bitlair_closed.d/20_phone_off b/bitlair_closed.d/20_phone_off new file mode 100755 index 0000000..f25e3b3 --- /dev/null +++ b/bitlair_closed.d/20_phone_off @@ -0,0 +1,7 @@ +#!/bin/bash + +# Switches off the phones. +poe-switch 1 2 +sleep 1 +poe-switch 2 2 +sleep 1 diff --git a/bitlair_closed.d/20_statsdisplay_poweroff b/bitlair_closed.d/20_statsdisplay_poweroff new file mode 100755 index 0000000..2d67060 --- /dev/null +++ b/bitlair_closed.d/20_statsdisplay_poweroff @@ -0,0 +1,3 @@ +#!/bin/bash + +ssh -o ConnectTimeout=1 root@statsbak.bitlair.nl shutdown -h now diff --git a/bitlair_closed.d/80_irc b/bitlair_closed.d/80_irc new file mode 100755 index 0000000..7ce731b --- /dev/null +++ b/bitlair_closed.d/80_irc @@ -0,0 +1,3 @@ +#!/bin/bash + +irc-say "Bitlair is now closed" diff --git a/bitlair_closed.d/80_twitter b/bitlair_closed.d/80_twitter new file mode 100644 index 0000000..ccb98f3 --- /dev/null +++ b/bitlair_closed.d/80_twitter @@ -0,0 +1,3 @@ +#!/bin/bash + +bitlair-tweet "We are closed." diff --git a/bitlair_open.d/10_log b/bitlair_open.d/10_log new file mode 100755 index 0000000..01ff553 --- /dev/null +++ b/bitlair_open.d/10_log @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Space opened on $(date)" >> /var/log/spacestate.log diff --git a/bitlair_open.d/10_mqtt b/bitlair_open.d/10_mqtt new file mode 100755 index 0000000..fb11134 --- /dev/null +++ b/bitlair_open.d/10_mqtt @@ -0,0 +1,3 @@ +#!/bin/bash + +mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state' -m 'open' diff --git a/bitlair_open.d/20_ledboard_poweron b/bitlair_open.d/20_ledboard_poweron new file mode 100755 index 0000000..5b1f632 --- /dev/null +++ b/bitlair_open.d/20_ledboard_poweron @@ -0,0 +1,6 @@ +#!/bin/bash + +# Switches on the led-board. + +apc-switch 23 on +sleep 1 diff --git a/bitlair_open.d/20_music_poweron b/bitlair_open.d/20_music_poweron new file mode 100755 index 0000000..efdd8b5 --- /dev/null +++ b/bitlair_open.d/20_music_poweron @@ -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 diff --git a/bitlair_open.d/20_phone_on b/bitlair_open.d/20_phone_on new file mode 100755 index 0000000..70fb65d --- /dev/null +++ b/bitlair_open.d/20_phone_on @@ -0,0 +1,7 @@ +#!/bin/bash + +# Switches on the phones. +poe-switch 1 1 +sleep 1 +poe-switch 2 1 +sleep 1 diff --git a/bitlair_open.d/20_statsdisplay_poweron b/bitlair_open.d/20_statsdisplay_poweron new file mode 100755 index 0000000..1469f76 --- /dev/null +++ b/bitlair_open.d/20_statsdisplay_poweron @@ -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 diff --git a/bitlair_open.d/80_irc b/bitlair_open.d/80_irc new file mode 100755 index 0000000..b3423da --- /dev/null +++ b/bitlair_open.d/80_irc @@ -0,0 +1,3 @@ +#!/bin/bash + +irc-say "Bitlair is now open!" diff --git a/bitlair_open.d/80_twitter b/bitlair_open.d/80_twitter new file mode 100644 index 0000000..1ff8c87 --- /dev/null +++ b/bitlair_open.d/80_twitter @@ -0,0 +1,3 @@ +#!/bin/bash + +bitlair-tweet "We are OPEN!" diff --git a/djo_closed.d/10_mqtt b/djo_closed.d/10_mqtt new file mode 100755 index 0000000..b2756f5 --- /dev/null +++ b/djo_closed.d/10_mqtt @@ -0,0 +1,3 @@ +#!/bin/bash + +mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state/djo' -m 'closed' diff --git a/djo_closed.d/20_ledboard_poweroff b/djo_closed.d/20_ledboard_poweroff new file mode 120000 index 0000000..6184364 --- /dev/null +++ b/djo_closed.d/20_ledboard_poweroff @@ -0,0 +1 @@ +../bitlair_closed.d/20_ledboard_poweroff \ No newline at end of file diff --git a/djo_closed.d/20_music_poweroff b/djo_closed.d/20_music_poweroff new file mode 120000 index 0000000..08796cd --- /dev/null +++ b/djo_closed.d/20_music_poweroff @@ -0,0 +1 @@ +../bitlair_closed.d/20_music_poweroff \ No newline at end of file diff --git a/djo_closed.d/20_statsdisplay_poweroff b/djo_closed.d/20_statsdisplay_poweroff new file mode 120000 index 0000000..35ac623 --- /dev/null +++ b/djo_closed.d/20_statsdisplay_poweroff @@ -0,0 +1 @@ +../bitlair_closed.d/20_statsdisplay_poweroff \ No newline at end of file diff --git a/djo_closed.d/80_irc b/djo_closed.d/80_irc new file mode 100755 index 0000000..0d233a8 --- /dev/null +++ b/djo_closed.d/80_irc @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "DJO is now open" | nc 127.0.0.1 31337 diff --git a/djo_open.d/10_mqtt b/djo_open.d/10_mqtt new file mode 100755 index 0000000..f1eebcf --- /dev/null +++ b/djo_open.d/10_mqtt @@ -0,0 +1,3 @@ +#!/bin/bash + +mqtt-simple -r -h mqtt.bitlair.nl -p 'bitlair/state/djo' -m 'open' diff --git a/djo_open.d/20_ledboard_poweron b/djo_open.d/20_ledboard_poweron new file mode 120000 index 0000000..cd17c08 --- /dev/null +++ b/djo_open.d/20_ledboard_poweron @@ -0,0 +1 @@ +../bitlair_open.d/20_ledboard_poweron \ No newline at end of file diff --git a/djo_open.d/20_music_poweron b/djo_open.d/20_music_poweron new file mode 120000 index 0000000..7e9f8bd --- /dev/null +++ b/djo_open.d/20_music_poweron @@ -0,0 +1 @@ +../bitlair_open.d/20_music_poweron \ No newline at end of file diff --git a/djo_open.d/20_statsdisplay_poweron b/djo_open.d/20_statsdisplay_poweron new file mode 120000 index 0000000..c41c1c1 --- /dev/null +++ b/djo_open.d/20_statsdisplay_poweron @@ -0,0 +1 @@ +../bitlair_open.d/20_statsdisplay_poweron \ No newline at end of file diff --git a/djo_open.d/80_irc b/djo_open.d/80_irc new file mode 100755 index 0000000..0d233a8 --- /dev/null +++ b/djo_open.d/80_irc @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "DJO is now open" | nc 127.0.0.1 31337 diff --git a/spacestated b/spacestated index f069c1f..f64dd1f 100755 --- a/spacestated +++ b/spacestated @@ -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 = [