If selected, start hostapd as a systemd service in multi-user.target using a configuration file at the specified file path.
Signed-off-by: Gavin Schenk <[email protected]> --- Changes in v2: - depends on initmethod systemd - Remove ability to rename config file in order to reduce overall complexity - provide dummy config /etc/hostapd/hostapd.conf - use menuconfig in hostapd.in My motivation for the patch was to remove local customization in the BSP. Unfortunately, without the option to rename the configuration, I must continue to to maintain local changes. Does this patch add value or should we discard it? projectroot/etc/hostapd/hostapd.conf | 2 ++ .../usr/lib/systemd/system/hostapd.service | 15 +++++++++++++++ rules/hostapd.in | 15 +++++++++++++-- rules/hostapd.make | 9 +++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 projectroot/etc/hostapd/hostapd.conf create mode 100644 projectroot/usr/lib/systemd/system/hostapd.service diff --git a/projectroot/etc/hostapd/hostapd.conf b/projectroot/etc/hostapd/hostapd.conf new file mode 100644 index 000000000..9e425a8c3 --- /dev/null +++ b/projectroot/etc/hostapd/hostapd.conf @@ -0,0 +1,2 @@ +# This is a placeholder. You have to provide a real configuration here. See +# hostapd.conf in package hostapd as a starting point for you own configuration. diff --git a/projectroot/usr/lib/systemd/system/hostapd.service b/projectroot/usr/lib/systemd/system/hostapd.service new file mode 100644 index 000000000..bef52896c --- /dev/null +++ b/projectroot/usr/lib/systemd/system/hostapd.service @@ -0,0 +1,15 @@ +[Unit] +Description=Access point and authentication server for Wi-Fi and Ethernet +After=network.target +ConditionFileNotEmpty=/etc/hostapd/hostapd.conf + +[Service] +Type=forking +PIDFile=/run/hostapd.pid +Restart=on-failure +RestartSec=2 +Environment=DAEMON_CONF=/etc/hostapd/hostapd.conf +ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid ${DAEMON_CONF} + +[Install] +WantedBy=multi-user.target diff --git a/rules/hostapd.in b/rules/hostapd.in index 6ac6be52c..9c95fe373 100644 --- a/rules/hostapd.in +++ b/rules/hostapd.in @@ -1,10 +1,10 @@ ## SECTION=networking -config HOSTAPD +menuconfig HOSTAPD tristate select OPENSSL select LIBNL3 - prompt "hostapd" + prompt "hostapd " help IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator @@ -21,3 +21,14 @@ config HOSTAPD authentication without requiring an external RADIUS authentication server), and RADIUS authentication server for EAP authentication. + +if HOSTAPD + +config HOSTAPD_SYSTEMD_UNIT + bool + prompt "Enable systemd support" + depends on INITMETHOD_SYSTEMD + help + Install systemd units to start this service on startup. + +endif diff --git a/rules/hostapd.make b/rules/hostapd.make index 2d061b5d4..11b5ca1b0 100644 --- a/rules/hostapd.make +++ b/rules/hostapd.make @@ -74,6 +74,15 @@ $(STATEDIR)/hostapd.targetinstall: @$(call install_copy, hostapd, 0, 0, 0755, -, /usr/sbin/hostapd) @$(call install_alternative, hostapd, 0, 0, 0644, /etc/hostapd/hostapd.conf) +ifdef PTXCONF_HOSTAPD_SYSTEMD_UNIT + @$(call install_alternative, hostapd, 0, 0, 0644, \ + /usr/lib/systemd/system/hostapd.service) + @$(call install_link, hostapd, ../hostapd.service, \ + /lib/systemd/system/multi-user.target.wants/hostapd.service) + @$(call install_alternative, hostapd, 0, 0, 0644, \ + /etc/hostapd/hostapd.conf) +endif + @$(call install_finish, hostapd) @$(call touch) -- 2.39.5
