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