From c7f5a0b8de85b064e3cbe454ef31ff2854ec52e4 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 12 Nov 2024 16:09:38 +0100 Subject: [PATCH] metronom-login: create --- home.nix | 1 + metronom-login.script.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 metronom-login.script.nix diff --git a/home.nix b/home.nix index f924086..913606c 100644 --- a/home.nix +++ b/home.nix @@ -55,6 +55,7 @@ in deadd-notification-center #marker.pkgs.end# (import ./traewelling.script.nix) + (import ./metronom-login.script.nix) (import ./plans.script.nix) (import ./todos.script.nix) (import ./plans-backend.script.nix) diff --git a/metronom-login.script.nix b/metronom-login.script.nix new file mode 100644 index 0000000..ef68b8f --- /dev/null +++ b/metronom-login.script.nix @@ -0,0 +1,20 @@ +with import {}; + +pkgs.writeShellScriptBin "metronom-login" '' + #!/bin/sh + + netif="$(cat ~/.direct-netif)" + echo "netif is (~/.direct-netif) $netif" + ip="$(dog -1 wifi.metronom.de @10.101.1.1 A)" + echo "ip is $ip" + csrf="$(curl --interface $(cat ~/.direct-netif) "$ip/de/" | grep CSRFToken | sed -E 's/.*value="([0-9a-f]*)".*/\1/')" + echo "csrf is $csrf" + resp="$(curl --interface $(cat ~/.direct-netif) "$ip/de/" -X POST -H "Cookie: csrf=$csrf" --data-raw "login=true&CSRFToken=$csrf" | wc -l)" + if [ $resp = 1 ] ; then + echo OK + else + echo unsuccessful + exit 1 + fi +'' +