From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 06 Sep 2024 15:59:35 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smZUu-001tbo-04 for lore@lore.pengutronix.de; Fri, 06 Sep 2024 15:59:35 +0200 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1smZUt-0004Zw-0x; Fri, 06 Sep 2024 15:59:35 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1smZUh-0004Zm-Fe; Fri, 06 Sep 2024 15:59:23 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1smZUg-005xbc-QD; Fri, 06 Sep 2024 15:59:22 +0200 Received: from mol by dude05.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1smZUg-00630P-2T; Fri, 06 Sep 2024 15:59:22 +0200 Date: Fri, 6 Sep 2024 15:59:22 +0200 From: Michael Olbrich To: Gavin Schenk Message-ID: References: <20240826054325.1426208-1-g.schenk@eckelmann.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240826054325.1426208-1-g.schenk@eckelmann.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain Subject: Re: [ptxdist] [PATCH] hostapd: Add systemd service unit X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false 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 > --- > 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 |