From ff22c7b819a24d2760d6cb24d81c294ef2b275d6 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Wed, 28 Jul 2021 14:41:14 +0200
Subject: [PATCH] community/iwd: improve init script, add logging

---
 community/iwd/APKBUILD  | 13 ++++++++-----
 community/iwd/iwd.confd | 18 ++++++++++++++++++
 community/iwd/iwd.initd | 13 ++++++++++---
 3 files changed, 36 insertions(+), 8 deletions(-)
 create mode 100644 community/iwd/iwd.confd

diff --git a/community/iwd/APKBUILD b/community/iwd/APKBUILD
index e50f80b89f47..6f6e6e649323 100644
--- a/community/iwd/APKBUILD
+++ b/community/iwd/APKBUILD
@@ -14,6 +14,7 @@ subpackages="$pkgname-doc $pkgname-openrc"
 source="https://mirrors.edge.kernel.org/pub/linux/network/wireless/iwd-$pkgver.tar.gz
 	dbus-netdev-group.patch
 	iwd.initd
+	iwd.confd
 	main.conf
 	iwd.post-upgrade
 	"
@@ -43,17 +44,19 @@ check() {
 
 package() {
 	make DESTDIR="$pkgdir" install
+
 	install -m750 -d "$pkgdir"/var/lib/$pkgname
-	install -m755 -D "$srcdir"/$pkgname.initd \
-		"$pkgdir"/etc/init.d/$pkgname
-	install -m644 -D "$srcdir"/main.conf \
-		"$pkgdir"/etc/$pkgname/main.conf
+	install -m644 -D "$srcdir"/main.conf "$pkgdir"/etc/$pkgname/main.conf
+
+	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
 }
 
 sha512sums="
 398080ead7194bbfe4db4b292ee866c926a515b0b87e3c6afa96ae1949706caafb59081eef81ed42d227f5d0beb075b65dbb392f6af8d10d3978e373b28c3a29  iwd-1.15.tar.gz
 7d3bc26b558ebfd22335b946f09abd5326e885275979c617af7def1468ade23ba7605f3b13aaf91836035c130aaec04be0ff2708a898f3ae835e0eef4e78fa0e  dbus-netdev-group.patch
-1a913fa19a76a18d92b8f44cb5b4b99a64b4e2f7d2b4a486bf1ba2f939aea7dcca772fca91483011ada58aaa3addc29c76ececd708b2187e57f72aa040ac77e6  iwd.initd
+fdad00af35c688c9575a629b28d36a72e4aca0f69adeccff2618f92dc03126c7bcf096b5eec10fcee10b2a176942fa994b5fc5acd4c00c38306849c5cb29fc39  iwd.initd
+edd81077b9b3b8aa98da71c0f318efb23432d9ff81484718d48f8edc4e31bd51d17caa7f9b87a0bbda7c7f015804d80bbdb612627f06a86f435a82eee9e302e2  iwd.confd
 09f4097e653cfecfa1e4bc7b4843832785d0a8ef2a8ecf7daa3d5be704d9ac311fbbecf9f9f5b8b1c75beff894e4cf0d8fda4d6ff728a638dedf77aff0197179  main.conf
 414cb08e01735a66dfb57eac7f308ce75f8f7adf679c5e38418293a0acb2398f9b4df4dd50a6756e48eb03b86de1546e2f852a28677842f2c453a0db86d49f71  iwd.post-upgrade
 "
diff --git a/community/iwd/iwd.confd b/community/iwd/iwd.confd
new file mode 100644
index 000000000000..916ce5d339f3
--- /dev/null
+++ b/community/iwd/iwd.confd
@@ -0,0 +1,18 @@
+# Configuration for /etc/init.d/iwd
+
+# A comma-separated list of patterns specifying the network interfaces that
+# iwd is allowed to manage. Defaults to any wireless interfaces.
+#allowed_interfaces=
+
+# A comma-separated list of patterns specifying the network interfaces that
+# iwd should ignore.
+#ignored_interfaces=
+
+# Extra options for iwd(8).
+#command_args=
+
+# Log messages are redirected to syslog. Set to empty string to disable.
+#error_logger="logger -t iwd -p daemon.info"
+
+# Uncomment to use process supervisor.
+#supervisor="supervise-daemon"
diff --git a/community/iwd/iwd.initd b/community/iwd/iwd.initd
index 3ae8fc436af7..3c6bdc001b91 100644
--- a/community/iwd/iwd.initd
+++ b/community/iwd/iwd.initd
@@ -1,10 +1,17 @@
 #!/sbin/openrc-run
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
 
-pidfile="/run/iwd.pid"
+description="iNet wireless daemon"
+
+: ${error_logger="logger -t iwd -p daemon.info"}
+
 command="/usr/libexec/iwd"
 command_background="yes"
+command_args="
+	${allowed_interfaces:+"--interfaces \"$allowed_interfaces\""}
+	${ignored_interfaces:+"--nointerfaces \"$ignored_interfaces\""}
+	${command_args:-}
+	"
+pidfile="/run/$RC_SVCNAME.pid"
 
 depend() {
 	need dbus
-- 
GitLab