X-Git-Url: https://git.jankratochvil.net/?a=blobdiff_plain;f=bin%2Ffup;fp=bin%2Ffup;h=0da386d19bf4fce37bdff05f246207129223da97;hb=546f559042c1f9686bcb1d518b87696468543d5a;hp=fbd129ce44384da3a2b88ed6f2b22c2ff86a31d4;hpb=2b479a1393c0310c532780f4a893e88b50c4f746;p=nethome.git diff --git a/bin/fup b/bin/fup index fbd129c..0da386d 100755 --- a/bin/fup +++ b/bin/fup @@ -65,10 +65,16 @@ sub change($) my($on)=@_; $on=($on ? 1 : 0); - login(); - my $change=simple("https://uzivatel.gtsnovera.cz/cgi-bin/fup.pl", - 'action.'.($on ? 'setManual' : 'unsetManual').'=1', - )->decoded_content() or die "change: ".$on; + my $try=0; + my $change; + do { + print "!" if $try; + die "Looping to login" if $try++>0x10; + login(); + $change=simple("https://uzivatel.gtsnovera.cz/cgi-bin/fup.pl", + 'action.'.($on ? 'setManual' : 'unsetManual').'=1', + )->decoded_content() or die "change: ".$on; + } while $change=~m{No authentication cookie was sent.}; my $is_on =($change=~m{\bFUP active\b}); my $is_off=($change=~m{\bFUP not active\b}); $is_on==!$is_off or die $change."\nInvalid change state"; @@ -117,7 +123,6 @@ for (;;) { $tx_last=$tx; push @history,$on_now; print $on_now; - my $stable; $on=change(1) if $on==0 && history(1,$STABILIZE_ON); $on=change(0) if $on==1 && history(0,$STABILIZE_OFF); sleep $SECS;