diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dcd85f3..87cf06a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,7 @@ if (WERROR) add_compile_options(-Werror) endif() +add_subdirectory(config) add_subdirectory(packaging) add_subdirectory(src) diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt new file mode 100644 index 00000000..8f55c6e4 --- /dev/null +++ b/config/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory(linux) diff --git a/config/linux/CMakeLists.txt b/config/linux/CMakeLists.txt new file mode 100644 index 00000000..e9183a9c --- /dev/null +++ b/config/linux/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory(network) diff --git a/config/linux/network/CMakeLists.txt b/config/linux/network/CMakeLists.txt new file mode 100644 index 00000000..6d09032c --- /dev/null +++ b/config/linux/network/CMakeLists.txt @@ -0,0 +1,3 @@ + +add_subdirectory(cloud) +add_subdirectory(netplan) diff --git a/config/linux/network/cloud/99-disable-network-config.cfg b/config/linux/network/cloud/99-disable-network-config.cfg new file mode 100644 index 00000000..033e3fdb --- /dev/null +++ b/config/linux/network/cloud/99-disable-network-config.cfg @@ -0,0 +1 @@ +network: { config: disabled } \ No newline at end of file diff --git a/config/linux/network/cloud/CMakeLists.txt b/config/linux/network/cloud/CMakeLists.txt new file mode 100644 index 00000000..671f4e1d --- /dev/null +++ b/config/linux/network/cloud/CMakeLists.txt @@ -0,0 +1,7 @@ + +install( + FILES + ${CMAKE_CURRENT_LIST_DIR}/99-disable-network-config.cfg + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cloud/cloud.cfg.d + COMPONENT network-config +) diff --git a/config/linux/network/netplan/10-network-netremote-all.yaml b/config/linux/network/netplan/10-network-netremote-all.yaml new file mode 100644 index 00000000..27a32c74 --- /dev/null +++ b/config/linux/network/netplan/10-network-netremote-all.yaml @@ -0,0 +1,36 @@ +# +# This plan defines a network topology where a set of interfaces provide gateway services to wireless network clients. +# +# Netplan YAML reference: https://netplan.readthedocs.io/en/stable/netplan-yaml/ +# +# Instructions: +# 1. Identify all interfaces, ethernet or otherwise, that provide network services such as DHCP, DNS, etc. to wireless +# network clients. This will typically be, but is not limited to, a single ethernet interface. +# 2. For each interface identified above: +# a. Add a network interface definition entry according to its type ('ethernets', 'vlans', etc.) which disables all +# IP addressing. See the netplan yaml reference URL above for complete options if necessary. +# b. Add the interface name to the 'interfaces' property of the brgateway0 bridge definition to make the interface +# available to all bridge slaves. +# 3. Re-generate ("render") the plan using 'sudo netplan generate'. +# 4. Optionally validate the generated configuration using 'sudo netplan try'. +# 5. Apply the generated configuration using 'sudo netplan apply'. +# +# The default template describes a plan where a single ethernet network interface 'eno2' provides all gateway services. +# + +network: + version: 2 + renderer: networkd + ethernets: + eno2: # ** Change this to the interface that provides gateway network services (DHCP, DNS, etc.). ** + # Disable DHCP on all interfaces that will be part of the virtual bridge interface. + dhcp4: no + dhcp6: no + bridges: + # Define a bridge that will act as a gateway to wireless clients. + brgateway0: + # Configure the bridge to obtain its IP address using DHCP. + dhcp4: yes + # Include interfaces that provide the gateway services to wireless clients. DO NOT ADD wireless interfaces here. + interfaces: + - eno2 diff --git a/config/linux/network/netplan/CMakeLists.txt b/config/linux/network/netplan/CMakeLists.txt new file mode 100644 index 00000000..e16814b5 --- /dev/null +++ b/config/linux/network/netplan/CMakeLists.txt @@ -0,0 +1,7 @@ + +install( + FILES + ${CMAKE_CURRENT_LIST_DIR}/10-network-netremote-all.yaml + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/netplan + COMPONENT network-config +) diff --git a/packaging/deb/CMakeLists.txt b/packaging/deb/CMakeLists.txt index 23c6c4e6..4e78f27f 100644 --- a/packaging/deb/CMakeLists.txt +++ b/packaging/deb/CMakeLists.txt @@ -13,6 +13,7 @@ set(CPACK_COMPONENTS_ALL server hostapd dev + network-config ) include(CPack) diff --git a/src/linux/external/hostap/systemd/CMakeLists.txt b/src/linux/external/hostap/systemd/CMakeLists.txt index 05905b7d..66913bb1 100644 --- a/src/linux/external/hostap/systemd/CMakeLists.txt +++ b/src/linux/external/hostap/systemd/CMakeLists.txt @@ -5,14 +5,8 @@ configure_file( ) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/hostapd-debug@.service.in - ${CMAKE_CURRENT_BINARY_DIR}/hostapd-debug@.service - @ONLY -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/hostapd-release@.service.in - ${CMAKE_CURRENT_BINARY_DIR}/hostapd-release@.service + ${CMAKE_CURRENT_SOURCE_DIR}/hostapd@.service.in + ${CMAKE_CURRENT_BINARY_DIR}/hostapd@.service @ONLY ) @@ -37,26 +31,14 @@ install( install( FILES - ${CMAKE_CURRENT_BINARY_DIR}/hostapd-release@.service - CONFIGURATIONS Release - DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system - RENAME hostapd@.service - COMPONENT hostapd -) - -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/hostapd-debug@.service - CONFIGURATIONS Debug RelWithDebInfo MinSizeRel + ${CMAKE_CURRENT_BINARY_DIR}/hostapd@.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system - RENAME hostapd@.service COMPONENT hostapd ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/hostapd-genconfig@.service - CONFIGURATIONS Debug RelWithDebInfo MinSizeRel DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system COMPONENT hostapd ) diff --git a/src/linux/external/hostap/systemd/hostapd-example.conf.in b/src/linux/external/hostap/systemd/hostapd-example.conf.in index d027553e..05ed5c06 100644 --- a/src/linux/external/hostap/systemd/hostapd-example.conf.in +++ b/src/linux/external/hostap/systemd/hostapd-example.conf.in @@ -1,12 +1,4 @@ -# -# Default hostapd configuration file. -# -# To use this with the provided systemd service unit template hostapd@.service, -# (eg. via 'systemctl enable hostapd@wlan0'), copy this file to -# /etc/hostapd/hostapd-.conf. For example, to use it with wlan0, copy this file to -# /etc/hostapd/hostapd-wlan0.conf and specify the desired SSID after the 'ssid' property below. -# - +# Default (generated) hostapd configuration file. driver=nl80211 ctrl_interface=${CMAKE_INSTALL_FULL_RUNSTATEDIR}/hostapd ssid= @@ -15,6 +7,6 @@ channel=1 auth_algs=3 wpa=2 wpa_passphrase=password -wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256 SAE -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP \ No newline at end of file +wpa_key_mgmt=SAE +rsn_pairwise=CCMP +bridge=brgateway0 \ No newline at end of file diff --git a/src/linux/external/hostap/systemd/hostapd-genconfig@.service.in b/src/linux/external/hostap/systemd/hostapd-genconfig@.service.in index d06e3483..2ff6ecc7 100644 --- a/src/linux/external/hostap/systemd/hostapd-genconfig@.service.in +++ b/src/linux/external/hostap/systemd/hostapd-genconfig@.service.in @@ -1,9 +1,11 @@ [Unit] Description=Generate default hostapd configuration file AssertPathExists=@CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-example.conf +ConditionPathExists=!@CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf [Service] Type=oneshot RemainAfterExit=true ExecStart=/usr/bin/cp @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-example.conf @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf +ExecStart=/usr/bin/sed -i '/^#/d' @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf ExecStart=/usr/bin/sed -i 's/ssid=/ssid=%l-ap-%i/' @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf diff --git a/src/linux/external/hostap/systemd/hostapd-release@.service.in b/src/linux/external/hostap/systemd/hostapd-release@.service.in deleted file mode 100644 index b8eb971f..00000000 --- a/src/linux/external/hostap/systemd/hostapd-release@.service.in +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Hostapd Daemon -Requires=sys-subsystem-net-devices-%i.device -After=sys-subsystem-net-devices-%i.device -AssertPathExists=@CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf - -[Service] -Type=simple -Restart=on-failure -ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/hostapd -i %i @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf - -[Install] -WantedBy=default.target diff --git a/src/linux/external/hostap/systemd/hostapd-debug@.service.in b/src/linux/external/hostap/systemd/hostapd@.service.in similarity index 100% rename from src/linux/external/hostap/systemd/hostapd-debug@.service.in rename to src/linux/external/hostap/systemd/hostapd@.service.in