liminix/pkgs/ifwait/ifbridgeable.fnl
Raito Bezarius 5590fea16e
Some checks failed
build liminix / build_vm_qemu_mips (pull_request) Failing after 28s
feat(ifwait): add ifbridgeable script
This enable to wait for bridgeability of a WLAN interface via
`iwinfo`.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-09-07 21:09:17 +02:00

30 lines
790 B
Fennel

(local wlan (require :anoia.wlan))
(local { : assoc } (require :anoia))
(local { : msleep } (require :lualinux))
(fn parse-args [args]
(match args
["-v" & rest] (assoc (parse-args rest) :verbose true)
[linkname] {:link linkname}
_ nil))
(fn run [args poll-fn]
(let [parameters
(assert (parse-args args)
(.. "Usage: ifbridgeable [-v] ifname"))]
(when parameters.verbose
(print (.. "ifbridgeable: waiting for "
parameters.link " to be bridgeable")))
(while (not (poll-fn parameters.link))
(when parameters.verbose
(print (.. "ifbridgeable: waiting for " parameters.link " to be bridgeable")))
(msleep 500)
)
)
)
(when (not (= (. arg 0) "test"))
(run arg wlan.is-bridgeable))
{ : run }