Thorsten,

On Mon, Apr 18, 2022 at 07:44:11AM +0100, Mark Hindley wrote:
> There is already a wishlist bug with patch[1]. Maybe you could test and refine
> it?

I have had a quick look at this today and have the attached patch (based on
Patrick's original suggestions) for review and testing.

Thanks

Mark

diff --git a/debian/src/initscripts/Makefile b/debian/src/initscripts/Makefile
index 4646d5d5..b13eafa3 100644
--- a/debian/src/initscripts/Makefile
+++ b/debian/src/initscripts/Makefile
@@ -27,6 +27,7 @@ install:
 	chmod 755 $(DESTDIR)$(sysconfdir)/init.d/[a-z]*
 	chmod 755 $(DESTDIR)$(sysconfdir)/network/if-up.d/[a-z]*
 	chmod 755 $(DESTDIR)$(sysconfdir)/rc.local
+	chmod 755 $(DESTDIR)$(sysconfdir)/rc.shutdown
 	chmod 644 $(DESTDIR)/lib/init/*.sh
 	chmod -R g-w $(DESTDIR)
 
diff --git a/debian/src/initscripts/etc/init.d/rc.local b/debian/src/initscripts/etc/init.d/rc.local
index f83747e4..8ed74b0f 100644
--- a/debian/src/initscripts/etc/init.d/rc.local
+++ b/debian/src/initscripts/etc/init.d/rc.local
@@ -23,6 +23,16 @@ do_start() {
 	fi
 }
 
+do_stop() {
+	if [ -x /etc/rc.local.shutdown ]; then
+	        [ "$VERBOSE" != no ] && log_begin_msg "Running local shutdown scripts (/etc/rc.shutdown)"
+		/etc/rc.shutdown
+		ES=$?
+		[ "$VERBOSE" != no ] && log_end_msg $ES
+		return $ES
+	fi
+}
+
 case "$1" in
     start)
 	do_start
@@ -31,10 +41,14 @@ case "$1" in
         echo "Error: argument '$1' not supported" >&2
         exit 3
         ;;
-    stop|status)
+    status)
         # No-op
         exit 0
         ;;
+    stop)
+	do_stop
+        exit 0
+        ;;
     *)
         echo "Usage: $0 start|stop" >&2
         exit 3
diff --git a/debian/src/initscripts/etc/rc.shutdown b/debian/src/initscripts/etc/rc.shutdown
new file mode 100644
index 00000000..106c7f87
--- /dev/null
+++ b/debian/src/initscripts/etc/rc.shutdown
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+#
+# rc.shutdown
+#
+# This script is executed by /etc/init.d/rc.local stop.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+
+if test -d /etc/shutdown.d ; then
+	run-parts /etc/shutdown.d
+fi

Reply via email to