forked from DGNum/liminix
t #2
5 changed files with 45 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
default: fs.lua init.lua nl.lua svc.lua net/constants.lua
|
default: wlan.lua fs.lua init.lua nl.lua svc.lua net/constants.lua
|
||||||
|
|
||||||
test:
|
test:
|
||||||
ln -s . anoia
|
ln -s . anoia
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
, linotify
|
, linotify
|
||||||
, lua
|
, lua
|
||||||
, lualinux
|
, lualinux
|
||||||
|
, iwinfo
|
||||||
, cpio
|
, cpio
|
||||||
}:
|
}:
|
||||||
let pname = "anoia";
|
let pname = "anoia";
|
||||||
|
@ -12,7 +13,7 @@ in stdenv.mkDerivation {
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
nativeBuildInputs = [ fennel cpio ];
|
nativeBuildInputs = [ fennel cpio ];
|
||||||
buildInputs = with lua.pkgs; [ linotify lualinux ];
|
buildInputs = with lua.pkgs; [ linotify lualinux iwinfo ];
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
8
pkgs/anoia/wlan.fnl
Normal file
8
pkgs/anoia/wlan.fnl
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
(local { : nl80211 } (require :iwinfo))
|
||||||
|
|
||||||
|
(fn is-bridgeable [ifname]
|
||||||
|
(let [mode (nl80211.mode ifname)]
|
||||||
|
(or (= mode "Master") (= mode "Master (VLAN)"))
|
||||||
|
))
|
||||||
|
|
||||||
|
{ : is-bridgeable }
|
|
@ -1,6 +1,8 @@
|
||||||
{
|
{
|
||||||
lua
|
lua
|
||||||
, netlink-lua
|
, netlink-lua
|
||||||
|
, lualinux
|
||||||
|
, iwinfo
|
||||||
, writeFennelScript
|
, writeFennelScript
|
||||||
, runCommand
|
, runCommand
|
||||||
, anoia
|
, anoia
|
||||||
|
@ -8,4 +10,5 @@
|
||||||
runCommand "ifwait" {} ''
|
runCommand "ifwait" {} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp -p ${writeFennelScript "ifwait" [ anoia netlink-lua ] ./ifwait.fnl} $out/bin/ifwait
|
cp -p ${writeFennelScript "ifwait" [ anoia netlink-lua ] ./ifwait.fnl} $out/bin/ifwait
|
||||||
|
cp -p ${writeFennelScript "ifbridgeable" [ anoia lualinux iwinfo ] ./ifbridgeable.fnl} $out/bin/ifbridgeable
|
||||||
''
|
''
|
||||||
|
|
30
pkgs/ifwait/ifbridgeable.fnl
Normal file
30
pkgs/ifwait/ifbridgeable.fnl
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
(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 }
|
Loading…
Reference in a new issue