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

feat(makanek): run tarot service on tarot.kmein.r

This commit is contained in:
2021-12-15 00:10:06 +01:00
parent 5ade0a7011
commit e755ee06e2
2 changed files with 36 additions and 0 deletions

35
configs/tarot.nix Normal file
View File

@@ -0,0 +1,35 @@
{ config, pkgs, lib, ... }:
let
tarotPort = 7407;
tarotFiles = pkgs.fetchzip {
url = "https://c.krebsco.de/tarot.zip";
sha256 = "0jl5vdwlj17pqp94yj02xgsb1gyvs9i08m83kac0jdnhfjl2f75a";
stripRoot = false;
};
in
{
krebs.htgen.tarot = {
port = tarotPort;
user.name = "radio";
script = ''. ${pkgs.writers.writeDash "tarot" ''
case "$Method $Request_URI" in
"GET /")
if item=$(find ${toString tarotFiles} -type f | shuf -n1); then
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$(file -ib $item)"
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(wc -c < $item)
printf '\r\n'
cat $item
exit
fi
;;
esac
''}'';
};
services.nginx.virtualHosts."tarot.kmein.r" = {
locations."/".proxyPass = "http://127.0.0.1:${toString tarotPort}";
};
}