diff --git a/config/ap.nix b/config/ap.nix index 9996391..daf8dc2 100644 --- a/config/ap.nix +++ b/config/ap.nix @@ -1783,6 +1783,7 @@ }; priv43.type = "bridge"; }; + wifiOnLink.enable = false; wifi = { "pci0000:00/0000:00:00.0" = { channel = 100; diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index 56097be..0297acf 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -464,6 +464,13 @@ let } )); }; + wifiOnLink.enable = mkOption { + type = types.bool; + default = true; + description = '' + Install the wifi-on-link.sh script on OpenWRT devices. + ''; + }; }; }; diff --git a/nix/pkgs/ap.nix b/nix/pkgs/ap.nix index c3767f7..a736efc 100644 --- a/nix/pkgs/ap.nix +++ b/nix/pkgs/ap.nix @@ -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