metronom-login: create
This commit is contained in:
parent
29ae403d7d
commit
c7f5a0b8de
2 changed files with 21 additions and 0 deletions
1
home.nix
1
home.nix
|
@ -55,6 +55,7 @@ in
|
||||||
deadd-notification-center
|
deadd-notification-center
|
||||||
#marker.pkgs.end#
|
#marker.pkgs.end#
|
||||||
(import ./traewelling.script.nix)
|
(import ./traewelling.script.nix)
|
||||||
|
(import ./metronom-login.script.nix)
|
||||||
(import ./plans.script.nix)
|
(import ./plans.script.nix)
|
||||||
(import ./todos.script.nix)
|
(import ./todos.script.nix)
|
||||||
(import ./plans-backend.script.nix)
|
(import ./plans-backend.script.nix)
|
||||||
|
|
20
metronom-login.script.nix
Normal file
20
metronom-login.script.nix
Normal 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
|
||||||
|
''
|
||||||
|
|
Loading…
Add table
Reference in a new issue