From a1c702af6c1930c6355149e9c6f51590333f498a Mon Sep 17 00:00:00 2001 From: Packet Please Date: Fri, 16 Aug 2024 14:34:35 +0200 Subject: [PATCH] kub: automate custom VLAN tagging on kub-ap1 --- locations/kub.yml | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/locations/kub.yml b/locations/kub.yml index d5d25be14..fa95fcb92 100644 --- a/locations/kub.yml +++ b/locations/kub.yml @@ -19,6 +19,54 @@ hosts: - hostname: kub-ap1 role: ap model: "cudy_x6-v1" + host__rclocal__to_merge: + - '#' + - '# This script adjusts the configuration of vlans. This is especially' + - '# useful with uswflex and custom port configs' + - '#' + - '' + - '. /lib/functions.sh' + - '' + - 'handle_vlans() {' + - ' # untag the vlans on different ports based on their id' + - ' local uci_section="$1"' + - '' + - ' config_get vlan "$uci_section" vlan' + - ' config_get ports "$uci_section" ports' + - '' + - '' + - ' case "$vlan" in' + - ' 40)' + - ' # untag DHCP on LAN 1 and LAN 2' + - " port_config='wan:t lan1 lan2 lan3:t lan4:t'" + - ' ;;' + - ' *)' + - ' # do nothing for the other vlans' + - ' printf "Done.\n"' + - ' return' + - ' esac' + - '' + - ' # abort if config is applied already' + - ' if [ "$ports" = "$port_config" ]; then' + - ' printf "Vlan %d applied already.\n" "$vlan"' + - ' return' + - ' fi' + - '' + - ' printf "Port number: %d\n" "$vlan"' + - ' printf "Port config: %s\n" "$port_config"' + - '' + - ' printf "Configuring %s... " "$uci_section"' + - ' uci_set network "$uci_section" ports "$port_config"' + - ' printf "Done.\n"' + - '}' + - '' + - 'config_load network' + - '' + - 'config_foreach handle_vlans "bridge-vlan"' + - '' + - 'uci commit network' + - 'sync' + - 'reload_config' snmp_devices: - hostname: kub-simeon