metronom-login: create

This commit is contained in:
Daniella / Tove 2024-11-12 16:09:38 +01:00
parent 29ae403d7d
commit c7f5a0b8de
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 21 additions and 0 deletions

View file

@ -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)

20
metronom-login.script.nix Normal file
View file

@ -0,0 +1,20 @@
with import <nixpkgs> {};
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
''