getaddress.expect (1271B)
1 set timeout 60 2 3 spawn socat unix-connect:vm/console - 4 expect "s6-linux-init" 5 send "\r\n" 6 expect "#" 7 send "PS1=\$(echo 'I1JFQURZIyA=' | base64 -d); stty -echo\n" 8 expect "#READY#" 9 set FINISHED 0 10 set EXIT "1" 11 while { $FINISHED < 20 } { 12 send "ip address show dev ppp0 | grep ppp0\n" 13 expect { 14 "192.168.100.1" { set FINISHED 200; set EXIT 0; } 15 "can't find device" { send_user "waiting ..." ; sleep 3 } 16 "DOWN" { send_user "waiting ..." ; sleep 3 } 17 } 18 set FINISHED [ expr $FINISHED + 1 ] 19 } 20 expect "#READY#" 21 send "s6-svwait -U /run/service/wan.link.pppoe\n" 22 expect "#READY#" 23 24 set timeout 30 25 send "nft list set ip table-ip lan || touch /non/existent\n" 26 expect { 27 "{ \"lan\" }" { puts "lan found" } 28 "{ }" { puts "missing ifname"; exit 1 } 29 "No such file or directory" { exit 1 } 30 } 31 32 expect "#READY#" 33 34 # if the test fails for no apparent reason, it is quite likely because 35 # the firewall hasn't had time to reload after the new interface 36 # appears and you just have to make this sleep longer. Ew, yes 37 send "sleep 10; nft list set ip table-ip wan || touch /non/existent\n" 38 expect { 39 "{ \"ppp0\" }" { puts "ppp0 found " } 40 "{ }" { puts "missing ifname"; exit 1 } 41 "No such file or directory" { exit 1 } 42 timeout { exit 1 } 43 } 44 expect "#READY#" 45 46 exit $EXIT