Subject: [PATCH] testing/pounce: add init.d, conf.d, pre-install files

From: Thomas Faughnan <[email-masked]>
Date: Thu, 7 Jul 2022 00:21:05 -0400

This provides OpenRC service files to run pounce as a supervised
process, as well as a pre-install script which creates the pounce user
and group. Accordingly, these files are added to the APKBUILD.
---
 testing/pounce/APKBUILD           |  8 +++++++-
 testing/pounce/pounce.confd       |  5 +++++
 testing/pounce/pounce.initd       | 33 +++++++++++++++++++++++++++++++
 testing/pounce/pounce.pre-install |  6 ++++++
 4 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 testing/pounce/pounce.confd
 create mode 100644 testing/pounce/pounce.initd
 create mode 100644 testing/pounce/pounce.pre-install

diff --git a/testing/pounce/APKBUILD b/testing/pounce/APKBUILD
index 1c0b95a2cb..8e660a559b 100644
--- a/testing/pounce/APKBUILD
+++ b/testing/pounce/APKBUILD
@@ -10,7 +10,9 @@ license="GPL-3.0-or-later"
 options="!check" # No test suite
 makedepends="libretls-dev"
 subpackages="$pkgname-doc"
-source="https://git.causal.agency/pounce/snapshot/pounce-$pkgver.tar.gz"
+source="https://git.causal.agency/pounce/snapshot/pounce-$pkgver.tar.gz
+	$pkgname.initd
+	$pkgname.confd"
 
 build() {
 	./configure \
@@ -21,8 +23,12 @@ build() {
 
 package() {
 	make DESTDIR="$pkgdir" install
+	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
 }
 
 sha512sums="
 76fce4820c877202720505a96d45394027d88f9755fe9a96fb69e305699022d61f8dba7db524b0bc5058b5f999bcd02b82904525d3284b34a29ffbe64c1c3bc0  pounce-3.0.tar.gz
+4e848c12dac518485c07156540d7d6eba02d0c08de74803a7db26cbfd5fc175f61f2c7ad81d805d4e803c1eb3608efcf008f32fbbf8093e1d7f9b540133e20d9  pounce.initd
+4ed4026fb00425461f295f2e8eafe324072c828d03049feddeb8640693b9613ad17c79292c584433a12ba02fe852173abe26a4fc12cd0250f4ff4c893aa734ef  pounce.confd
 "
diff --git a/testing/pounce/pounce.confd b/testing/pounce/pounce.confd
new file mode 100644
index 0000000000..b82123b2b0
--- /dev/null
+++ b/testing/pounce/pounce.confd
@@ -0,0 +1,5 @@
+# Configuration for /etc/init.d/pounce
+
+#supervisor="supervise-daemon"
+#cfgfile="/etc/pounce/pounce.conf"
+#error_log="/var/log/pounce.log"
diff --git a/testing/pounce/pounce.initd b/testing/pounce/pounce.initd
new file mode 100644
index 0000000000..6d8cb9b923
--- /dev/null
+++ b/testing/pounce/pounce.initd
@@ -0,0 +1,33 @@
+#!/sbin/openrc-run
+
+name="pounce"
+description="Multi-client, TLS-only IRC bouncer"
+
+supervisor=${supervisor:-"supervise-daemon"}
+cfgfile=${cfgfile:-"/etc/$RC_SVCNAME.conf"}
+error_log=${error_log:-"/var/log/$RC_SVCNAME.log"}
+
+command="/usr/bin/pounce"
+command_user="pounce"
+command_args="$cfgfile"
+directory="/var/lib/$RC_SVCNAME"
+
+extra_started_commands="reload"
+description_reload="Reload TLS configuration"
+
+depend() {
+	need net
+	after firewall
+}
+
+start_pre() {
+	checkpath -d -o $command_user "$directory"
+	checkpath -f -o $command_user "$cfgfile"
+	checkpath -f -o $command_user "$error_log"
+}
+
+reload() {
+	ebegin "Reloading TLS configuration"
+	$supervisor $RC_SVCNAME --signal USR1
+	eend $?
+}
diff --git a/testing/pounce/pounce.pre-install b/testing/pounce/pounce.pre-install
new file mode 100644
index 0000000000..ddeb3674fc
--- /dev/null
+++ b/testing/pounce/pounce.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S pounce 2>/dev/null
+adduser -S -D -h /var/lib/pounce -s /sbin/nologin -G pounce -g pounce pounce 2>/dev/null
+
+exit 0
-- 
2.36.1