From e0c5b3f187310cae8f5ad0abb2e92d5aa79e94db Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 5 Sep 2021 21:52:47 +0200 Subject: puyak.r: announce doorstatus --- krebs/2configs/shack/doorstatus.sh | 74 ++++++++++++++++++++++++++++++++++++++ krebs/2configs/shack/reaktor.nix | 11 ++++++ 2 files changed, 85 insertions(+) create mode 100755 krebs/2configs/shack/doorstatus.sh diff --git a/krebs/2configs/shack/doorstatus.sh b/krebs/2configs/shack/doorstatus.sh new file mode 100755 index 000000000..11e710cfd --- /dev/null +++ b/krebs/2configs/shack/doorstatus.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# needs in path: +# curl jq +# creates and manages $PWD/state +set -euf + +send_reaktor(){ + # usage: send_reaktor "text" + echo "send_reaktor: $1" + curl -fsS http://localhost:7777 \ + -H content-type:application/json \ + -d "$(jq -n \ + --arg text "$1" '{ + command:"PRIVMSG", + params:["#shackspace",$text] + }' + )" +} + +open=$(shuf -n1 < state +fi diff --git a/krebs/2configs/shack/reaktor.nix b/krebs/2configs/shack/reaktor.nix index 40c121299..a31c7a687 100644 --- a/krebs/2configs/shack/reaktor.nix +++ b/krebs/2configs/shack/reaktor.nix @@ -16,4 +16,15 @@ } ]; }; + systemd.services.announce_doorstatus = { + startAt = "*:0/1"; + path = with pkgs; [ curl jq ]; + script = builtins.readFile ./doorstatus.sh; + serviceConfig = { + DynamicUser = true; + StateDirectory = "doorstatus"; + WorkingDirectory = "/var/lib/doorstatus"; + PrivateTmp = true; + }; + }; } -- cgit v1.2.3