2016-12-11 02:45:45 +01:00
|
|
|
#!/usr/bin/env bash
|
2016-11-28 17:17:59 +01:00
|
|
|
|
2017-02-07 02:42:04 +01:00
|
|
|
{% macro uci_network_mgmt(ifname) -%}
|
|
|
|
set network.mgmt=interface
|
|
|
|
set network.mgmt.ifname={{ ifname }}
|
|
|
|
set network.mgmt.proto=static
|
|
|
|
set network.mgmt.ipaddr={{ pillar['hosts-inet']['mgmt'][hostname] }}
|
|
|
|
set network.mgmt.netmask=255.255.255.0
|
2017-02-07 02:44:38 +01:00
|
|
|
set network.mgmt.gateway={{ pillar['hosts-inet']['mgmt']['mgmt-gw'] }}
|
2018-06-23 00:12:35 +02:00
|
|
|
set network.mgmt.ip6addr={{ pillar['hosts-inet6']['dn42']['mgmt'][hostname] }}/64
|
|
|
|
set network.mgmt.ip6gw={{ pillar['hosts-inet6']['dn42']['mgmt']['mgmt-gw'] }}
|
2017-02-07 02:42:04 +01:00
|
|
|
delete network.mgmt.dns
|
2020-09-18 19:03:16 +02:00
|
|
|
add_list network.mgmt.dns=172.20.73.8
|
2017-02-07 02:42:04 +01:00
|
|
|
add_list network.mgmt.dns={{ pillar['hosts-inet']['core']['upstream1'] }}
|
2018-06-23 00:12:35 +02:00
|
|
|
add_list network.mgmt.dns={{ pillar['hosts-inet6']['dn42']['core']['upstream1'] }}
|
2017-02-07 02:42:04 +01:00
|
|
|
add_list network.mgmt.dns={{ pillar['hosts-inet']['core']['upstream2'] }}
|
2018-06-23 00:12:35 +02:00
|
|
|
add_list network.mgmt.dns={{ pillar['hosts-inet6']['dn42']['core']['upstream2'] }}
|
2017-02-07 02:42:04 +01:00
|
|
|
{%- endmacro %}
|
|
|
|
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- if conf.get('firstboot') %}
|
|
|
|
ssh-keygen -R 192.168.1.1
|
|
|
|
|
|
|
|
ssh root@192.168.1.1 \
|
2016-12-11 02:45:45 +01:00
|
|
|
"ash -e -x" <<__SSH__
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- else %}
|
|
|
|
ssh root@{{ pillar['hosts-inet']['mgmt'][hostname] }} \
|
2016-12-11 02:45:45 +01:00
|
|
|
"ash -e -x" <<__SSH__
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
# Set root password
|
2016-12-06 03:09:42 +01:00
|
|
|
echo -e '{{ conf['password'] }}\n{{ conf['password'] }}' | passwd
|
2016-11-28 17:17:59 +01:00
|
|
|
|
2017-02-07 02:11:32 +01:00
|
|
|
# add ssh pubkey
|
|
|
|
echo "{{ pillar['ssh']['pubkey'] }}" > /etc/dropbear/authorized_keys
|
2016-11-28 17:17:59 +01:00
|
|
|
|
|
|
|
# System configuration
|
|
|
|
uci batch <<__UCI__
|
|
|
|
set system.@system[0].hostname={{ hostname }}
|
|
|
|
set dhcp.@dnsmasq[0].enabled=0
|
|
|
|
|
|
|
|
delete network.globals.ula_prefix
|
|
|
|
delete network.lan
|
|
|
|
delete network.wan
|
|
|
|
delete network.wan6
|
|
|
|
delete wireless.default_radio0
|
|
|
|
delete wireless.default_radio1
|
|
|
|
|
2016-11-29 18:10:32 +01:00
|
|
|
{%- set bridges = {} %}
|
|
|
|
{%- if conf.get('lan-access') %}
|
|
|
|
{%- do bridges.__setitem__(conf['lan-access'], True) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- for path, radio in conf['radios'].items() %}
|
|
|
|
{%- for ssid, ssidconf in radio['ssids'].items() %}
|
|
|
|
{%- do bridges.__setitem__(ssidconf['net'], True) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2016-11-29 16:18:35 +01:00
|
|
|
{%- if conf['model'] == 'TL-WDR4300' %}
|
2016-11-29 18:10:32 +01:00
|
|
|
{# These models have a shared Ethernet chip for LAN/WAN and therefore need switching #}
|
2016-11-29 16:18:35 +01:00
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
2016-11-29 18:10:32 +01:00
|
|
|
set network.@switch_vlan[0].ports='0t 1t'
|
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 1t 2 3 4 5'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 1t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2016-11-29 18:10:32 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
2016-11-29 16:18:35 +01:00
|
|
|
|
2016-12-06 03:09:42 +01:00
|
|
|
{%- elif conf['model'] == 'TL-WR1043ND' %}
|
|
|
|
{# These models have a shared Ethernet chip with separate CPU ports for LAN/WAN and therefore need switching #}
|
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
|
|
|
set network.@switch_vlan[0].ports='5t 6t'
|
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
2018-09-20 20:55:35 +02:00
|
|
|
# 0: eth1; 1-4: LAN ports in reverse; 5: WAN port; 6: eth0
|
2016-12-06 03:09:42 +01:00
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0 1 2 3 4 5t'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='5t 6t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2016-12-06 03:09:42 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.{{ net }}.ifname='eth1'
|
|
|
|
{%- else %}
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2016-12-11 01:44:22 +01:00
|
|
|
{%- elif conf['model'] == 'TL-Archer-C7v2' %}
|
|
|
|
{# These models have a shared Ethernet chip with separate CPU ports for LAN/WAN and therefore need switching #}
|
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
|
|
|
set network.@switch_vlan[0].ports='1t 6t'
|
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
|
|
|
# 0: eth1; 1: WAN port; 2-5: LAN ports; 6: eth0
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0 1t 2 3 4 5'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='1t 6t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2016-12-11 01:44:22 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.{{ net }}.ifname='eth1'
|
|
|
|
{%- else %}
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2018-11-12 20:52:26 +01:00
|
|
|
{%- elif conf['model'] == 'TL-Archer-C7v4' or conf['model'] == 'TL-Archer-C7v5' %}
|
2018-04-24 21:17:59 +02:00
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
|
|
|
set network.@switch_vlan[0].ports='0t 1t'
|
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
|
|
|
# 0: eth0; 1: WAN port; 2-5: LAN ports
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 1t 2 3 4 5'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 1t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2018-09-13 23:51:38 +02:00
|
|
|
{%- elif conf['model'] == 'TL-WR1043NDv4' or conf['model'] == 'TL-WR1043NDv5' %}
|
2018-05-24 01:13:43 +02:00
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
2018-05-31 01:53:57 +02:00
|
|
|
set network.@switch_vlan[0].ports='0t 5t'
|
2018-05-24 01:13:43 +02:00
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
|
|
|
# 0: eth0; 1-4: LAN ports; 5: WAN port
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 1 2 3 4 5t'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0t 5t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-01-17 22:02:25 +01:00
|
|
|
{%- elif conf['model'] == 'TL-WR841Nv8' %}
|
|
|
|
{# Like v9 but with eth0/1 switched #}
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=0
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2017-01-17 22:02:25 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{# Add WAN VLAN to bridge #}
|
|
|
|
{%- set ports = ['eth0.' ~ pillar['vlans'][net]] %}
|
|
|
|
{# Add LAN ports to bridge #}
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
{%- do ports.append('eth1') %}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
set network.{{ net }}.ifname='{{ ' '.join(ports) }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-05-11 21:05:04 +02:00
|
|
|
{%- elif conf['model'] == 'TL-WR740Nv4' %}
|
|
|
|
{# Separate eth0/1 interfaces for LAN/WAN #}
|
|
|
|
{# eth0 - Port 0: eth0, Port 2: LAN1, Port 3: LAN2, Port 4: LAN3, Port 1: LAN4 #}
|
|
|
|
{# eth1 - WAN #}
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=0
|
|
|
|
|
|
|
|
{{ uci_network_mgmt('eth1.1') }}
|
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{# Add WAN VLAN to bridge #}
|
|
|
|
{%- set ports = ['eth1.' ~ pillar['vlans'][net]] %}
|
|
|
|
{# Add LAN ports to bridge #}
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
{%- do ports.append('eth0') %}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
set network.{{ net }}.ifname='{{ ' '.join(ports) }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2021-01-22 21:00:42 +01:00
|
|
|
{%- elif conf['model'] == 'TL-WA901NDv3' or conf['model'] == 'Ubnt-UniFi-AP-AC-LR' %}
|
2017-01-26 17:50:33 +01:00
|
|
|
{# Only eth0 exists, no switch #}
|
2017-02-07 02:42:04 +01:00
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2017-01-26 17:50:33 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{# Add WAN VLAN to bridge #}
|
|
|
|
set network.{{ net }}.ifname='{{ 'eth0.' ~ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2021-01-22 21:00:42 +01:00
|
|
|
{%- elif conf['model'] == 'Ubnt-UAP-nanoHD' %}
|
|
|
|
{# no switch, eth0 exists but is not usable, using "lan" instead #}
|
|
|
|
|
|
|
|
{{ uci_network_mgmt('lan.1') }}
|
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
{# Add WAN VLAN to bridge #}
|
|
|
|
set network.{{ net }}.ifname='{{ 'lan.' ~ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2019-04-14 19:45:48 +02:00
|
|
|
{%- elif conf['model'] == 'DIR-615H1' or conf['model'] == 'DIR-615D4' %}
|
|
|
|
{# All DIR-615 share the same port layout #}
|
2017-01-20 22:55:48 +01:00
|
|
|
delete network.lan_dev
|
|
|
|
delete network.wan_dev
|
|
|
|
{# switch is cpu port 6, wan:cpu port 4, lan port 1 is cpu port 3, lan port 2 is 2 etc #}
|
|
|
|
set network.@switch[0]=switch
|
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=1
|
|
|
|
set network.@switch[0].name=switch0
|
|
|
|
set network.@switch_vlan[0]=switch_vlan
|
|
|
|
set network.@switch_vlan[0].device='switch0'
|
|
|
|
set network.@switch_vlan[0].vlan='1'
|
|
|
|
set network.@switch_vlan[0].ports='4t 6t'
|
|
|
|
set network.@switch_vlan[0].comment='mgmt'
|
|
|
|
{% set switchnum = 1 %}
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}]=switch_vlan
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].device='switch0'
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].vlan='{{ pillar['vlans'][net] }}'
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='0 1 2 3 4t 6t'
|
|
|
|
{%- else %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].ports='4t 6t'
|
|
|
|
{%- endif %}
|
|
|
|
set network.@switch_vlan[{{ switchnum }}].comment='{{ net }}'
|
|
|
|
{% set switchnum = switchnum + 1 %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth0.1') }}
|
2017-01-20 22:55:48 +01:00
|
|
|
|
|
|
|
{%- for net in bridges.keys() %}
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
|
|
|
#TODO: this should consider lan-access
|
|
|
|
set network.{{ net }}.ifname='eth0.{{ pillar['vlans'][net] }}'
|
|
|
|
{%- endfor %}
|
|
|
|
|
2016-11-29 16:18:35 +01:00
|
|
|
{%- else %}
|
2016-11-29 18:10:32 +01:00
|
|
|
{# All other models may have separate Ethernet chips for LAN/WAN #}
|
2016-11-28 17:17:59 +01:00
|
|
|
set network.@switch[0].reset=1
|
|
|
|
set network.@switch[0].enable=1
|
|
|
|
set network.@switch[0].enable_vlan=0
|
|
|
|
|
2017-02-07 02:43:26 +01:00
|
|
|
{{ uci_network_mgmt('eth1.1') }}
|
2016-11-28 17:17:59 +01:00
|
|
|
|
2016-11-29 18:10:32 +01:00
|
|
|
{%- for net in bridges.keys() %}
|
2016-11-28 17:17:59 +01:00
|
|
|
|
|
|
|
set network.{{ net }}=interface
|
|
|
|
set network.{{ net }}.type=bridge
|
|
|
|
set network.{{ net }}.proto=static
|
2016-11-29 18:10:32 +01:00
|
|
|
{# Add WAN VLAN to bridge #}
|
|
|
|
{%- set ports = ['eth1.' ~ pillar['vlans'][net]] %}
|
|
|
|
{# Add LAN ports to bridge #}
|
|
|
|
{%- if conf.get('lan-access') == net %}
|
|
|
|
{%- do ports.append('eth0') %}
|
|
|
|
{%- endif %}
|
|
|
|
|
2016-11-28 17:17:59 +01:00
|
|
|
set network.{{ net }}.ifname='{{ ' '.join(ports) }}'
|
2016-11-29 18:10:32 +01:00
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
{%- endif %}
|
2016-11-28 17:17:59 +01:00
|
|
|
|
2017-07-13 01:03:31 +02:00
|
|
|
{%- set index = { 'radio': 0, 'iface': 0 } %}
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- for path, radio in conf['radios'].items() %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.radio{{ index.radio }}=wifi-device
|
|
|
|
set wireless.radio{{ index.radio }}.type=mac80211
|
|
|
|
set wireless.radio{{ index.radio }}.country=DE
|
|
|
|
set wireless.radio{{ index.radio }}.channel={{ radio['channel'] }}
|
|
|
|
set wireless.radio{{ index.radio }}.path={{ path }}
|
|
|
|
set wireless.radio{{ index.radio }}.hwmode={{ radio.get('hwmode') or '11n' }}
|
|
|
|
set wireless.radio{{ index.radio }}.htmode={{ radio.get('htmode') or 'HT20' }}
|
|
|
|
set wireless.radio{{ index.radio }}.noscan=1
|
|
|
|
delete wireless.radio{{ index.radio }}.disabled
|
2016-11-28 17:17:59 +01:00
|
|
|
|
|
|
|
{%- for ssid, ssidconf in radio['ssids'].items() %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}=wifi-iface
|
2017-07-13 00:41:00 +02:00
|
|
|
{%- if radio['channel'] < 15 %}
|
2018-04-14 22:49:17 +02:00
|
|
|
{%- if conf['version'] == "nightly" %}
|
2018-04-14 22:40:47 +02:00
|
|
|
{%- set ifprefix = 'wlan2_' %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set ifprefix = 'wlan2-' %}
|
|
|
|
{%- endif %}
|
2017-07-13 00:41:00 +02:00
|
|
|
{%- else %}
|
2018-04-14 22:49:17 +02:00
|
|
|
{%- if conf['version'] == "nightly" %}
|
2018-04-14 22:40:47 +02:00
|
|
|
{%- set ifprefix = 'wlan5_' %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set ifprefix = 'wlan5-' %}
|
|
|
|
{%- endif %}
|
2017-07-13 00:41:00 +02:00
|
|
|
{%- endif %}
|
|
|
|
{%- if ssidconf.get('wpa-eap') %}
|
2018-04-14 22:49:17 +02:00
|
|
|
{%- if conf['version'] == "nightly" %}
|
2018-04-14 22:40:47 +02:00
|
|
|
{%- set ifsuffix = '_eap' %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set ifsuffix = '-eap' %}
|
|
|
|
{%- endif %}
|
2017-07-13 00:41:00 +02:00
|
|
|
{%- else %}
|
|
|
|
{%- set ifsuffix = '' %}
|
|
|
|
{%- endif %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.ifname={{ ifprefix }}{{ ssidconf['net'] }}{{ ifsuffix }}
|
|
|
|
set wireless.wifi{{ index.iface }}.device=radio{{ index.radio }}
|
|
|
|
set wireless.wifi{{ index.iface }}.ssid='{{ ssid }}'
|
|
|
|
set wireless.wifi{{ index.iface }}.mode=ap
|
|
|
|
set wireless.wifi{{ index.iface }}.network={{ ssidconf['net'] }}
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- if ssidconf.get('psk') %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.encryption=psk2
|
|
|
|
set wireless.wifi{{ index.iface }}.key='{{ ssidconf['psk'] }}'
|
2017-06-24 05:09:56 +02:00
|
|
|
{%- elif ssidconf.get('wpa-eap') %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.encryption=wpa2
|
|
|
|
set wireless.wifi{{ index.iface }}.server='{{ ssidconf['wpa-eap']['server'] }}'
|
|
|
|
set wireless.wifi{{ index.iface }}.port='{{ ssidconf['wpa-eap']['port'] }}'
|
2017-07-13 01:24:07 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.auth_secret='{{ ssidconf['wpa-eap']['secret'] }}'
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- else %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.encryption=none
|
2021-02-03 01:09:15 +01:00
|
|
|
delete wireless.wifi{{ index.iface }}.key
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- endif %}
|
2017-07-13 01:03:31 +02:00
|
|
|
set wireless.wifi{{ index.iface }}.mcast_rate=18000
|
2016-11-28 17:17:59 +01:00
|
|
|
|
2017-07-13 01:08:00 +02:00
|
|
|
{%- set x = index.update({ 'iface': index.iface + 1 }) %}
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- endfor %}
|
2017-07-13 01:08:00 +02:00
|
|
|
{%- set x = index.update({ 'radio': index.radio + 1 }) %}
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
commit
|
|
|
|
__UCI__
|
|
|
|
|
2016-12-11 02:25:48 +01:00
|
|
|
# Cronjob that makes sure WiFi is only visible when server with all
|
|
|
|
# the gateways is reachable
|
|
|
|
cat >/etc/crontabs/root <<__CRON__
|
2016-12-11 02:45:45 +01:00
|
|
|
* * * * * /usr/sbin/wifi-on-link.sh
|
2016-12-11 02:25:48 +01:00
|
|
|
__CRON__
|
2016-12-11 02:45:45 +01:00
|
|
|
cat >/usr/sbin/wifi-on-link.sh <<__SH__
|
2016-12-11 02:25:48 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if (ping -c 1 -W 3 {{ pillar['hosts-inet']['mgmt']['server1'] }}) ; then
|
|
|
|
REACHABLE=y
|
|
|
|
else
|
|
|
|
REACHABLE=n
|
|
|
|
fi
|
|
|
|
|
2017-03-28 16:52:42 +02:00
|
|
|
if [ "\\\$(cat /sys/class/net/wlan2-pub/operstate)" == "up" ] ; then
|
2016-12-11 02:25:48 +01:00
|
|
|
UP=y
|
|
|
|
else
|
|
|
|
UP=n
|
|
|
|
fi
|
|
|
|
|
2021-02-03 00:50:20 +01:00
|
|
|
{%- if conf.get("error-led") %}
|
2021-02-03 00:59:13 +01:00
|
|
|
ERROR_LED=/sys/class/leds/{{ conf["error-led"] }}/brightness
|
2021-02-03 01:02:55 +01:00
|
|
|
[ \\\$REACHABLE = y ] && echo 0 > \\\$ERROR_LED
|
|
|
|
[ \\\$REACHABLE = n ] && echo 1 > \\\$ERROR_LED
|
2021-02-03 00:50:20 +01:00
|
|
|
{%- endif %}
|
2021-02-03 00:59:13 +01:00
|
|
|
|
|
|
|
[ \\\$REACHABLE = y ] && [ \\\$UP = n ] && wifi up
|
|
|
|
[ \\\$REACHABLE = n ] && [ \\\$UP = y ] && wifi down
|
2016-12-11 02:25:48 +01:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
__SH__
|
2016-12-11 02:45:45 +01:00
|
|
|
chmod a+rx /usr/sbin/wifi-on-link.sh
|
|
|
|
/etc/init.d/cron restart
|
2016-12-11 02:25:48 +01:00
|
|
|
|
2017-03-28 17:30:05 +02:00
|
|
|
for svc in dnsmasq uhttpd ; do
|
|
|
|
rm /etc/rc.d/*\$svc
|
|
|
|
/etc/init.d/\$svc stop
|
|
|
|
done
|
|
|
|
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- if conf.get('firstboot') %}
|
2016-12-22 23:58:38 +01:00
|
|
|
reboot
|
2016-11-28 17:17:59 +01:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
__SSH__
|
|
|
|
|
2017-02-07 02:36:15 +01:00
|
|
|
echo "Base configuration done \\o/"
|
|
|
|
echo "Later run: `dirname $0`/ap_install_collectd.sh {{ pillar['hosts-inet']['mgmt'][hostname] }}"
|