mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] hostapd: Add systemd service unit
@ 2024-08-26  5:43 Gavin Schenk
  2024-09-06 13:59 ` Michael Olbrich
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin Schenk @ 2024-08-26  5:43 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

If selected, start hostapd as a systemd service in multi-user.target.
Make it possible to rename the configuration file, if needed.

Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
   Notes:
      I based the service file on the one that is shipped with debian, but
      removed the Documentation node. I removed (for me) unneeded
      EnvironmentFile=-/etc/default/hostapd and $DAEMON_OPTS as well, RFC.

      My system is shipped with template /etc/hostapd/hostapd.conf that contains
      @SSID@ as placeholder. The customer API, configuring WLAN, is to edit this
      file and place it as /etc/hostapd-device.conf before restarting the
      machine. This is the reason for HOSTAPD_SYSTEMD_UNIT_CONFIG.


.../usr/lib/systemd/system/hostapd.service    | 15 ++++++++++++++
 rules/hostapd.in                              | 20 +++++++++++++++++++
 rules/hostapd.make                            | 11 ++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 projectroot/usr/lib/systemd/system/hostapd.service

diff --git a/projectroot/usr/lib/systemd/system/hostapd.service b/projectroot/usr/lib/systemd/system/hostapd.service
new file mode 100644
index 000000000..5e715b60d
--- /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=@HOSTAPD_CONFIG_FILEPATH@
+
+[Service]
+Type=forking
+PIDFile=/run/hostapd.pid
+Restart=on-failure
+RestartSec=2
+Environment=DAEMON_CONF=@HOSTAPD_CONFIG_FILEPATH@
+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..74a0dd45f 100644
--- a/rules/hostapd.in
+++ b/rules/hostapd.in
@@ -21,3 +21,23 @@ config HOSTAPD
 	  authentication without requiring an external RADIUS
 	  authentication server), and RADIUS authentication server for
 	  EAP authentication.
+
+if HOSTAPD
+
+config HOSTAPD_SYSTEMD
+	prompt "Enable systemd support"
+	default false
+	bool
+
+config HOSTAPD_SYSTEMD_UNIT
+	default HOSTAPD_SYSTEMD
+	bool
+
+config HOSTAPD_SYSTEMD_UNIT_CONFIG
+	prompt "Configuration file used by unit"
+	default "/etc/hostapd/hostapd.conf"
+	string
+	help
+	  Configuration used, when starting hostapd"
+
+endif
diff --git a/rules/hostapd.make b/rules/hostapd.make
index 2d061b5d4..7d3d4ec62 100644
--- a/rules/hostapd.make
+++ b/rules/hostapd.make
@@ -74,6 +74,17 @@ $(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_replace, hostapd, /usr/lib/systemd/system/hostapd.service, \
+		@HOSTAPD_CONFIG_FILEPATH@, \
+		"$(call remove_quotes,$(PTXCONF_HOSTAPD_SYSTEMD_UNIT_CONFIG))")
+
+	@$(call install_link, hostapd, ../hostapd.service, \
+		/lib/systemd/system/multi-user.target.wants/hostapd.service)
+endif
+
 	@$(call install_finish, hostapd)
 
 	@$(call touch)
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist] [PATCH] hostapd: Add systemd service unit
  2024-08-26  5:43 [ptxdist] [PATCH] hostapd: Add systemd service unit Gavin Schenk
@ 2024-09-06 13:59 ` Michael Olbrich
  2024-10-08 13:23   ` [ptxdist] [PATCH v2] " Gavin Schenk
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2024-09-06 13:59 UTC (permalink / raw)
  To: Gavin Schenk; +Cc: ptxdist

On Mon, Aug 26, 2024 at 07:43:05AM +0200, Gavin Schenk wrote:
> If selected, start hostapd as a systemd service in multi-user.target.
> Make it possible to rename the configuration file, if needed.
> 
> Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> ---
>    Notes:
>       I based the service file on the one that is shipped with debian, but
>       removed the Documentation node. I removed (for me) unneeded
>       EnvironmentFile=-/etc/default/hostapd and $DAEMON_OPTS as well, RFC.
> 
>       My system is shipped with template /etc/hostapd/hostapd.conf that contains
>       @SSID@ as placeholder. The customer API, configuring WLAN, is to edit this
>       file and place it as /etc/hostapd-device.conf before restarting the
>       machine. This is the reason for HOSTAPD_SYSTEMD_UNIT_CONFIG.

I thinks this is too complex. I'd like a fixed path with a config that is
installed here as well, so:

- use /etc/hostapd/hostapd.conf directly
- install it with install_alternative and provide a dummy file with a
  comment in it, that a real configuration is needed.

If you need something special then you can:
- in your BSP create a symlink projectroot/etc/hostapd/hostapd.conf -> /dev/null
  That way the file is not installed.
- In your own package, create /etc/hostapd/hostapd.conf as a symlink that
  points to the correct path.

> 
> 
> .../usr/lib/systemd/system/hostapd.service    | 15 ++++++++++++++
>  rules/hostapd.in                              | 20 +++++++++++++++++++
>  rules/hostapd.make                            | 11 ++++++++++
>  3 files changed, 46 insertions(+)
>  create mode 100644 projectroot/usr/lib/systemd/system/hostapd.service
> 
> diff --git a/projectroot/usr/lib/systemd/system/hostapd.service b/projectroot/usr/lib/systemd/system/hostapd.service
> new file mode 100644
> index 000000000..5e715b60d
> --- /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=@HOSTAPD_CONFIG_FILEPATH@
> +
> +[Service]
> +Type=forking
> +PIDFile=/run/hostapd.pid
> +Restart=on-failure
> +RestartSec=2
> +Environment=DAEMON_CONF=@HOSTAPD_CONFIG_FILEPATH@
> +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..74a0dd45f 100644
> --- a/rules/hostapd.in
> +++ b/rules/hostapd.in
> @@ -21,3 +21,23 @@ config HOSTAPD

Packages with suboptions should use 'menuconfig' and the prompts needs to
be expanded with spaces to align the '->'. Look at other packages for an
example.

>  	  authentication without requiring an external RADIUS
>  	  authentication server), and RADIUS authentication server for
>  	  EAP authentication.
> +
> +if HOSTAPD
> +
> +config HOSTAPD_SYSTEMD
> +	prompt "Enable systemd support"
> +	default false

false is the default, so this is not needed.

> +	bool
> +
> +config HOSTAPD_SYSTEMD_UNIT
> +	default HOSTAPD_SYSTEMD
> +	bool

Why two options? Just one should be enough. And depend on
INITMETHOD_SYSTEMD.

Michael

> +
> +config HOSTAPD_SYSTEMD_UNIT_CONFIG
> +	prompt "Configuration file used by unit"
> +	default "/etc/hostapd/hostapd.conf"
> +	string
> +	help
> +	  Configuration used, when starting hostapd"
> +
> +endif
> diff --git a/rules/hostapd.make b/rules/hostapd.make
> index 2d061b5d4..7d3d4ec62 100644
> --- a/rules/hostapd.make
> +++ b/rules/hostapd.make
> @@ -74,6 +74,17 @@ $(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_replace, hostapd, /usr/lib/systemd/system/hostapd.service, \
> +		@HOSTAPD_CONFIG_FILEPATH@, \
> +		"$(call remove_quotes,$(PTXCONF_HOSTAPD_SYSTEMD_UNIT_CONFIG))")
> +
> +	@$(call install_link, hostapd, ../hostapd.service, \
> +		/lib/systemd/system/multi-user.target.wants/hostapd.service)
> +endif
> +
>  	@$(call install_finish, hostapd)
>  
>  	@$(call touch)
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ptxdist] [PATCH v2] hostapd: Add systemd service unit
  2024-09-06 13:59 ` Michael Olbrich
@ 2024-10-08 13:23   ` Gavin Schenk
  2024-10-25  7:32     ` [ptxdist] [APPLIED] " Michael Olbrich
  2024-10-25 10:36     ` [ptxdist] [PATCH v2] " Michael Olbrich
  0 siblings, 2 replies; 8+ messages in thread
From: Gavin Schenk @ 2024-10-08 13:23 UTC (permalink / raw)
  To: m.olbrich; +Cc: Gavin Schenk, ptxdist

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 <g.schenk@eckelmann.de>
---

 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




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist] [APPLIED] hostapd: Add systemd service unit
  2024-10-08 13:23   ` [ptxdist] [PATCH v2] " Gavin Schenk
@ 2024-10-25  7:32     ` Michael Olbrich
  2024-10-25 11:20       ` Artur Wiebe
  2024-10-25 10:36     ` [ptxdist] [PATCH v2] " Michael Olbrich
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2024-10-25  7:32 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

Thanks, applied as 49049c01b0a932c74c77b64f1b42c85141fec8e4.

Michael

[sent from post-receive hook]

On Fri, 25 Oct 2024 09:32:55 +0200, Gavin Schenk <g.schenk@eckelmann.de> wrote:
> 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 <g.schenk@eckelmann.de>
> Message-Id: <20241008132331.1372881-1-g.schenk@eckelmann.de>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/projectroot/etc/hostapd/hostapd.conf b/projectroot/etc/hostapd/hostapd.conf
> new file mode 100644
> index 000000000000..9e425a8c3d71
> --- /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 000000000000..bef52896c28e
> --- /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 6ac6be52cd6f..9c95fe37387e 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 2d061b5d4412..11b5ca1b0e08 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)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist] [PATCH v2] hostapd: Add systemd service unit
  2024-10-08 13:23   ` [ptxdist] [PATCH v2] " Gavin Schenk
  2024-10-25  7:32     ` [ptxdist] [APPLIED] " Michael Olbrich
@ 2024-10-25 10:36     ` Michael Olbrich
  2024-10-25 11:16       ` Gavin Schenk
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Olbrich @ 2024-10-25 10:36 UTC (permalink / raw)
  To: Gavin Schenk; +Cc: ptxdist

On Tue, Oct 08, 2024 at 03:23:31PM +0200, Gavin Schenk wrote:
> 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 <g.schenk@eckelmann.de>
> ---
> 
>  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?

It's absolutely valuable. In the general case, we can have hostapd running
with just an kconfig option and a custom config file (and that one is
always needed anyways).

And I think even your use-case, the customization is simplified:
You can provide your own projectroot/usr/lib/systemd/system/hostapd.service
(which changes less often than e.g. hostapd.make) that uses your custom
hostapd.conf and a "projectroot/etc/hostapd/hostapd.conf -> /dev/null"
symlink.
That's much simpler dann a modified hostapd.make or your own rule to
install the files.

Michael
PS: I understand why you would like to have a custom path upstream, but the
reality is, that everybody has a different config file that needs to be
loaded from a custom location and allowing that in general is a
maintenance nightmare for upstream PTXdist.

>  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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist] [PATCH v2] hostapd: Add systemd service unit
  2024-10-25 10:36     ` [ptxdist] [PATCH v2] " Michael Olbrich
@ 2024-10-25 11:16       ` Gavin Schenk
  0 siblings, 0 replies; 8+ messages in thread
From: Gavin Schenk @ 2024-10-25 11:16 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: ptxdist

Hey Michael,

I really appreciate the effort and time you put into this feedback, thanks.

>> 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?
>
> It's absolutely valuable. In the general case, we can have hostapd running
> with just an kconfig option and a custom config file (and that one is
> always needed anyways).
>
> And I think even your use-case, the customization is simplified:
> You can provide your own projectroot/usr/lib/systemd/system/hostapd.service
> (which changes less often than e.g. hostapd.make) that uses your custom
> hostapd.conf and a "projectroot/etc/hostapd/hostapd.conf -> /dev/null"
> symlink.
> That's much simpler dann a modified hostapd.make or your own rule to
> install the files.
>
> Michael
> PS: I understand why you would like to have a custom path upstream, but the
> reality is, that everybody has a different config file that needs to be
> loaded from a custom location and allowing that in general is a
> maintenance nightmare for upstream PTXdist.

Understand, full ACK!

gsc



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist]  [APPLIED] hostapd: Add systemd service unit
  2024-10-25  7:32     ` [ptxdist] [APPLIED] " Michael Olbrich
@ 2024-10-25 11:20       ` Artur Wiebe
  2024-10-25 14:34         ` Michael Olbrich
  0 siblings, 1 reply; 8+ messages in thread
From: Artur Wiebe @ 2024-10-25 11:20 UTC (permalink / raw)
  To: ptxdist

Hi Michael,

here /etc/hostapd/hostapd.conf would be installed twice!

BR,
Artur

On Friday, 25 October, 2024 09:32 CEST, Michael Olbrich <m.olbrich@pengutronix.de> wrote:

> Thanks, applied as 49049c01b0a932c74c77b64f1b42c85141fec8e4.
> 
> Michael
> 
> [sent from post-receive hook]
> 
> On Fri, 25 Oct 2024 09:32:55 +0200, Gavin Schenk <g.schenk@eckelmann.de> wrote:
> > 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 <g.schenk@eckelmann.de>
> > Message-Id: <20241008132331.1372881-1-g.schenk@eckelmann.de>
> > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> > 
> > diff --git a/projectroot/etc/hostapd/hostapd.conf b/projectroot/etc/hostapd/hostapd.conf
> > new file mode 100644
> > index 000000000000..9e425a8c3d71
> > --- /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 000000000000..bef52896c28e
> > --- /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 6ac6be52cd6f..9c95fe37387e 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 2d061b5d4412..11b5ca1b0e08 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)
/etc/hostapd/hostapd.conf is already installed above!
> > +endif
> > +
> >  	@$(call install_finish, hostapd)
> >  
> >  	@$(call touch)
>




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ptxdist] [APPLIED] hostapd: Add systemd service unit
  2024-10-25 11:20       ` Artur Wiebe
@ 2024-10-25 14:34         ` Michael Olbrich
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Olbrich @ 2024-10-25 14:34 UTC (permalink / raw)
  To: ptxdist

On Fri, Oct 25, 2024 at 01:20:17PM +0200, Artur Wiebe wrote:
> Hi Michael,
> 
> here /etc/hostapd/hostapd.conf would be installed twice!

Right, we're already installing a sample hostapd.conf... I'll remove the
duplicate install_alternative and the dummy file.

Michael

> BR,
> Artur
> 
> On Friday, 25 October, 2024 09:32 CEST, Michael Olbrich <m.olbrich@pengutronix.de> wrote:
> 
> > Thanks, applied as 49049c01b0a932c74c77b64f1b42c85141fec8e4.
> > 
> > Michael
> > 
> > [sent from post-receive hook]
> > 
> > On Fri, 25 Oct 2024 09:32:55 +0200, Gavin Schenk <g.schenk@eckelmann.de> wrote:
> > > 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 <g.schenk@eckelmann.de>
> > > Message-Id: <20241008132331.1372881-1-g.schenk@eckelmann.de>
> > > Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> > > 
> > > diff --git a/projectroot/etc/hostapd/hostapd.conf b/projectroot/etc/hostapd/hostapd.conf
> > > new file mode 100644
> > > index 000000000000..9e425a8c3d71
> > > --- /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 000000000000..bef52896c28e
> > > --- /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 6ac6be52cd6f..9c95fe37387e 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 2d061b5d4412..11b5ca1b0e08 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)
> /etc/hostapd/hostapd.conf is already installed above!
> > > +endif
> > > +
> > >  	@$(call install_finish, hostapd)
> > >  
> > >  	@$(call touch)
> >
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-25 14:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-26  5:43 [ptxdist] [PATCH] hostapd: Add systemd service unit Gavin Schenk
2024-09-06 13:59 ` Michael Olbrich
2024-10-08 13:23   ` [ptxdist] [PATCH v2] " Gavin Schenk
2024-10-25  7:32     ` [ptxdist] [APPLIED] " Michael Olbrich
2024-10-25 11:20       ` Artur Wiebe
2024-10-25 14:34         ` Michael Olbrich
2024-10-25 10:36     ` [ptxdist] [PATCH v2] " Michael Olbrich
2024-10-25 11:16       ` Gavin Schenk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox