pkgs/ap: don't install wifi-on-link.sh on ap58

This commit is contained in:
Astro 2022-01-18 21:21:45 +01:00
parent 01933d17ca
commit e6651c440d
3 changed files with 38 additions and 28 deletions

View File

@ -1783,6 +1783,7 @@
}; };
priv43.type = "bridge"; priv43.type = "bridge";
}; };
wifiOnLink.enable = false;
wifi = { wifi = {
"pci0000:00/0000:00:00.0" = { "pci0000:00/0000:00:00.0" = {
channel = 100; channel = 100;

View File

@ -464,6 +464,13 @@ let
} }
)); ));
}; };
wifiOnLink.enable = mkOption {
type = types.bool;
default = true;
description = ''
Install the wifi-on-link.sh script on OpenWRT devices.
'';
};
}; };
}; };

View File

@ -307,39 +307,41 @@ in ''
uci commit uci commit
# Cronjob that makes sure WiFi is only visible when server with all ${lib.optionalString hostConfig.wifiOnLink.enable ''
# the gateways is reachable # Cronjob that makes sure WiFi is only visible when server with all
cat >/etc/crontabs/root <<__CRON__ # the gateways is reachable
* * * * * /usr/sbin/wifi-on-link.sh cat >/etc/crontabs/root <<__CRON__
__CRON__ #* * * * * /usr/sbin/wifi-on-link.sh
cat >/usr/sbin/wifi-on-link.sh <<__SH__ __CRON__
#!/bin/sh cat >/usr/sbin/wifi-on-link.sh <<__SH__
#!/bin/sh
if (ping -c 1 -W 3 ${config.site.net.mgmt.hosts4.mgmt-gw}) ; then if (ping -c 1 -W 3 ${config.site.net.mgmt.hosts4.mgmt-gw}) ; then
REACHABLE=y REACHABLE=y
else else
REACHABLE=n REACHABLE=n
fi fi
if [ "\\\$(cat /sys/class/net/wlan2-pub/operstate)" == "up" ] ; then if [ "\\\$(cat /sys/class/net/wlan2-pub/operstate)" == "up" ] ; then
UP=y UP=y
else else
UP=n UP=n
fi fi
if [ -e /sys/class/leds/blue:dome ] ; then if [ -e /sys/class/leds/blue:dome ] ; then
ERROR_LED=/sys/class/leds/blue:dome/brightness ERROR_LED=/sys/class/leds/blue:dome/brightness
[ \\\$REACHABLE = y ] && echo 0 > \\\$ERROR_LED [ \\\$REACHABLE = y ] && echo 0 > \\\$ERROR_LED
[ \\\$REACHABLE = n ] && echo 1 > \\\$ERROR_LED [ \\\$REACHABLE = n ] && echo 1 > \\\$ERROR_LED
fi fi
[ \\\$REACHABLE = y ] && [ \\\$UP = n ] && wifi up [ \\\$REACHABLE = y ] && [ \\\$UP = n ] && wifi up
[ \\\$REACHABLE = n ] && [ \\\$UP = y ] && wifi down [ \\\$REACHABLE = n ] && [ \\\$UP = y ] && wifi down
exit 0 exit 0
__SH__ __SH__
chmod a+rx /usr/sbin/wifi-on-link.sh chmod a+rx /usr/sbin/wifi-on-link.sh
/etc/init.d/cron restart /etc/init.d/cron restart
''}
for svc in dnsmasq uhttpd ; do for svc in dnsmasq uhttpd ; do
rm -f /etc/rc.d/*\$svc rm -f /etc/rc.d/*\$svc