Subject: [PATCH 1/2] Add scripts for boot clean and setup

From: Lorenzo Puliti <[email-masked]>
Date: Mon, 1 Jun 2026 01:15:15 +0200

add seedfiles-clean and seedfiles-setup initscripts;
d/rules: by default don't start after install (pointless since they
should only run during boot and shutdown)
Use the seedfiles. prefix for scripts in debian/ to make dh happy
and avoid the warning
"Named prefix-less debhelper config files will trigger an error
in compat 15 or later"
---
 debian/rules                          |  4 ++
 debian/seedfiles.seedfiles-clean.init | 68 +++++++++++++++++++++++++++
 debian/seedfiles.seedfiles-setup.init | 68 +++++++++++++++++++++++++++
 3 files changed, 140 insertions(+)
 create mode 100755 debian/seedfiles.seedfiles-clean.init
 create mode 100755 debian/seedfiles.seedfiles-setup.init

diff --git a/debian/rules b/debian/rules
index ffd9067..fd66ce0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,3 +5,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 %:
 		dh $@
+
+override_dh_installinit:
+	dh_installinit --name=seedfiles-clean --no-start
+	dh_installinit --name=seedfiles-setup --no-start
diff --git a/debian/seedfiles.seedfiles-clean.init b/debian/seedfiles.seedfiles-clean.init
new file mode 100755
index 0000000..17f404e
--- /dev/null
+++ b/debian/seedfiles.seedfiles-clean.init
@@ -0,0 +1,68 @@
+#! /bin/sh
+#
+### BEGIN INIT INFO
+# Provides:          seedfiles-clean
+# Required-Start:    $network $remote_fs $syslog
+# Required-Stop:     $network $remote_fs
+# Default-Start:     S
+# Default-Stop:      0 6
+# X-Stop-After:       udev
+# Short-Description: temporary files and dir cleanup
+### END INIT INFO
+#
+
+# Copyright: 2020,2026 Lorenzo Puliti <[email-masked]>
+# License: GPL-3+
+# originally written for the Debian opentmpfiles package (BSD-2) in 2020, see
+# https://salsa.debian.org/debian/opentmpfiles/-/merge_requests/1/
+# now adapted and relicensed to GPL-3+ for seedfiles Debian package
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+NAME=seedfiles-clean
+DESC='seedfiles cleanup service'
+DAEMON=/usr/bin/seedfiles
+
+#removed but not purged case
+[ ! -e "$DAEMON" ] && exit 0
+
+case "$1" in
+	start )
+		if [ "$RUNLEVEL" = "S" ] && [ "$PREVLEVEL" = "N" ]; then
+			install -d /run/seedfiles
+			if "$DAEMON"  --clean ; then
+				touch /run/seedfiles/clean
+				log_success_msg "seedfiles: cleanup complete"
+			else
+				log_failure_msg "seedfiles: cleanup failed"
+			fi
+		fi
+		;;
+	restart | reload | force-reload )
+		# No-op
+		;;
+	stop)
+		if [ "$RUNLEVEL" = "0" ] || [ "$RUNLEVEL" = "6" ]; then
+			if "$DAEMON"  --clean ; then
+				log_success_msg "seedfiles: cleanup complete"
+			else
+				log_failure_msg "seedfiles: cleanup failed"
+			fi
+		fi
+		;;
+	status)
+		if [ -e /run/seedfiles/clean ]; then
+                    log_success_msg "seedfiles: clenup already done"
+                else
+                    log_failure_msg "seedfiles: clenup failed"
+                fi
+		;;
+	*)
+		echo "Usage: seedfiles-clean [start|stop|status]" >&2
+		exit 3
+		;;
+esac
+
+:
diff --git a/debian/seedfiles.seedfiles-setup.init b/debian/seedfiles.seedfiles-setup.init
new file mode 100755
index 0000000..20da56a
--- /dev/null
+++ b/debian/seedfiles.seedfiles-setup.init
@@ -0,0 +1,68 @@
+#! /bin/sh
+#
+### BEGIN INIT INFO
+# Provides:          seedfiles-setup
+# Required-Start:    $network $remote_fs $syslog seedfiles-clean
+# Required-Stop:     $network $remote_fs seedfiles-clean
+# Default-Start:     S
+# Default-Stop:      0 6
+# X-Stop-After:       udev
+# Short-Description: create volatile files and directories
+### END INIT INFO
+#
+
+# Copyright: 2020,2026 Lorenzo Puliti <[email-masked]>
+# License: GPL-3+
+# originally written for the Debian opentmpfiles package (BSD-2) in 2020, see
+# https://salsa.debian.org/debian/opentmpfiles/-/merge_requests/1/
+# now adapted and relicensed to GPL-3+ for seedfiles Debian package
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+NAME=seedfiles-setup
+DESC='seedfiles setup service'
+DAEMON=/usr/bin/seedfiles
+
+#removed but not purged case
+[ ! -e "$DAEMON" ] && exit 0
+
+case "$1" in
+	start )
+		if [ "$RUNLEVEL" = "S" ] && [ "$PREVLEVEL" = "N" ]; then
+			install -d /run/seedfiles
+			if "$DAEMON"  --create --remove --boot --exclude-prefix=/dev ; then
+				touch /run/seedfiles/setup
+				log_success_msg "seedfiles: setup complete"
+			else
+				log_failure_msg "seedfiles: setup failed"
+			fi
+		fi
+		;;
+	restart | reload | force-reload )
+		# No-op
+		;;
+	stop)
+		if [ "$RUNLEVEL" = "0" ] || [ "$RUNLEVEL" = "6" ]; then
+			if "$DAEMON" --remove --boot --exclude-prefix=/dev ; then
+				log_success_msg "seedfiles: setup complete"
+			else
+				log_failure_msg "seedfiles: setup failed"
+			fi
+		fi
+		;;
+	status)
+		if [ -e /run/seedfiles/setup ]; then
+                    log_success_msg "seedfiles: setup already done"
+                else
+                    log_failure_msg "seedfiles: setup failed"
+                fi
+		;;
+	*)
+		echo "Usage: seedfiles-setup [start|stop|status]" >&2
+		exit 3
+		;;
+esac
+
+:
-- 
2.53.0