[packages/hostapd] add systemd units (adapted from debian)

atler atler at pld-linux.org
Mon Sep 6 16:13:48 CEST 2021


commit 5588f8dfe300a00faa8101b33bc28329c9264f47
Author: Jan Palus <atler at pld-linux.org>
Date:   Mon Sep 6 16:12:43 2021 +0200

    add systemd units (adapted from debian)

 hostapd.service  | 16 ++++++++++++++++
 hostapd.spec     | 15 +++++++++++++++
 hostapd at .service | 16 ++++++++++++++++
 3 files changed, 47 insertions(+)
---
diff --git a/hostapd.spec b/hostapd.spec
index d583081..c28235d 100644
--- a/hostapd.spec
+++ b/hostapd.spec
@@ -1,3 +1,7 @@
+#
+# Conditional build:
+%bcond_without	systemd		# don't package systemd units
+
 Summary:	HostAP - acts as an access point
 Summary(es.UTF-8):	HostAP - actúa como un punto de acceso
 Summary(pl.UTF-8):	HostAP - praca jako access point
@@ -9,6 +13,8 @@ Group:		Daemons
 Source0:	http://w1.fi/releases/%{name}-%{version}.tar.gz
 # Source0-md5:	f188fc53a495fe7af3b6d77d3c31dee8
 Source1:	%{name}.init
+Source2:	%{name}.service
+Source3:	%{name}@.service
 Patch0:		%{name}-config.patch
 Patch1:		%{name}-build-time-config.patch
 URL:		http://w1.fi/hostapd/
@@ -21,6 +27,7 @@ BuildRequires:	sqlite3-devel >= 3
 Requires(post,preun):	/sbin/chkconfig
 Requires:	openssl >= 1.0.2
 Requires:	rc-scripts
+%{?with_systemd:Requires:	systemd-units >= 38}
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -77,6 +84,10 @@ install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
 
 # hostapd hostapd_cli nt_password_hash hlr_auc_gw
 install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/hostapd
+%if %{with systemd}
+install -pD %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
+install -pD %{SOURCE3} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}@.service
+%endif
 install -p hostapd/hostapd $RPM_BUILD_ROOT/sbin
 install -p hostapd/hostapd_cli $RPM_BUILD_ROOT/sbin
 install -p hostapd/nt_password_hash $RPM_BUILD_ROOT/sbin
@@ -116,3 +127,7 @@ fi
 %attr(754,root,root) /etc/rc.d/init.d/hostapd
 %{_mandir}/man1/hostapd_cli.1*
 %{_mandir}/man8/hostapd.8*
+%if %{with systemd}
+%{systemdunitdir}/%{name}.service
+%{systemdunitdir}/%{name}@.service
+%endif
diff --git a/hostapd.service b/hostapd.service
new file mode 100644
index 0000000..b139519
--- /dev/null
+++ b/hostapd.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Access point and authentication server for Wi-Fi and Ethernet
+Documentation=man:hostapd(8)
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/hostapd.pid
+Restart=on-failure
+RestartSec=2
+Environment=HOSTAPD_CONF=/etc/hostap/hostapd.conf
+EnvironmentFile=-/etc/sysconfig/hostapd
+ExecStart=/sbin/hostapd -B -P /run/hostapd.pid $HOSTAPD_OPTS ${HOSTAPD_CONF}
+
+[Install]
+WantedBy=multi-user.target
diff --git a/hostapd at .service b/hostapd at .service
new file mode 100644
index 0000000..5be27f8
--- /dev/null
+++ b/hostapd at .service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Access point and authentication server for Wi-Fi and Ethernet (%I)
+Documentation=man:hostapd(8)
+After=network.target
+BindsTo=sys-subsystem-net-devices-%i.device
+
+[Service]
+Type=forking
+PIDFile=/run/hostapd.%i.pid
+Restart=on-failure
+RestartSec=2
+EnvironmentFile=-/etc/sysconfig/hostapd
+ExecStart=/sbin/hostapd -B -P /run/hostapd.%i.pid $HOSTAPD_OPTS /etc/hostap/%i.conf
+
+[Install]
+WantedBy=multi-user.target sys-subsystem-net-devices-%i.device
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/hostapd.git/commitdiff/5588f8dfe300a00faa8101b33bc28329c9264f47



More information about the pld-cvs-commit mailing list