1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

chore: organize battery, steam and praesenzlehre into imports

This commit is contained in:
2021-02-28 08:01:51 +01:00
parent 74b102e55e
commit cbb676bf00
4 changed files with 63 additions and 74 deletions

View File

@@ -4,6 +4,48 @@ let
in
{
imports = [
{
systemd.services.praesenzlehre = {
description = "Live Ticker zu praesenzlehre-berlin.org";
wants = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
startAt = "daily";
path = [ pkgs.curl pkgs.pup pkgs.bc ];
environment.BOT_TOKEN = lib.strings.fileContents <system-secrets/telegram/kmein.token>;
script = ''
set -efu
count_file=/tmp/praesenzlehre-berlin.org
set_count() {
echo $* > "$count_file"
}
get_count() {
cat "$count_file"
}
notify() {
curl -sSL -X POST -H 'Content-Type: application/json' \
-d "{\"chat_id\": \"@praesenzlehre_berlin\", \"text\": \"$*\"}" \
"https://api.telegram.org/bot$BOT_TOKEN/sendMessage"
}
test -f "$count_file" || set_count 0
count="$(get_count)"
new_count="$(curl -sSL https://praesenzlehre-berlin.org/ | pup '.dk-speakout-signature-count span text{}')"
if [ "$new_count" -gt "$count" ]; then
diff="$(echo "$new_count - $count" | bc)"
echo "$new_count (+ $diff)"
notify "$new_count Unterzeichner:innen! (+ $diff)"
set_count "$new_count"
fi
'';
};
}
./hardware-configuration.nix
<niveum/configs/hedgedoc.nix>
<niveum/configs/spacetime.nix>
@@ -64,45 +106,4 @@ in
};
environment.systemPackages = [ pkgs.vim pkgs.git pkgs.tmux ];
systemd.services.praesenzlehre = {
description = "Live Ticker zu praesenzlehre-berlin.org";
wants = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
startAt = "daily";
path = [ pkgs.curl pkgs.pup pkgs.bc ];
environment.BOT_TOKEN = lib.strings.fileContents <system-secrets/telegram/kmein.token>;
script = ''
set -efu
count_file=/tmp/praesenzlehre-berlin.org
set_count() {
echo $* > "$count_file"
}
get_count() {
cat "$count_file"
}
notify() {
curl -sSL -X POST -H 'Content-Type: application/json' \
-d "{\"chat_id\": \"@praesenzlehre_berlin\", \"text\": \"$*\"}" \
"https://api.telegram.org/bot$BOT_TOKEN/sendMessage"
}
test -f "$count_file" || set_count 0
count="$(get_count)"
new_count="$(curl -sSL https://praesenzlehre-berlin.org/ | pup '.dk-speakout-signature-count span text{}')"
if [ "$new_count" -gt "$count" ]; then
diff="$(echo "$new_count - $count" | bc)"
echo "$new_count (+ $diff)"
notify "$new_count Unterzeichner:innen! (+ $diff)"
set_count "$new_count"
fi
'';
};
}