[2019-02-28 21:41] Pierre Ynard <linkfa...@yahoo.fr>
> /etc/rc.local is currently installed from a static heredoc in
> initscripts.postinst. This isn't very clean, and also old systems don't
> benefit from new file versions on upgrades, and nothing handles its
> removal on uninstall.
>
> Please consider making /etc/rc.local a conffile instead.

It proved to be slightly more involved then I expected. If I just make
default /etc/rc.local part of package, dpkg will silently overwrite
already existing /etc/rc.local. To fix it, I had to move existing
/etc/rc.local to temporary file in preinst and move back in postinst.

If anybody knows how to push this work on some existing tool,
suggestions are welcome.


From c241125c29c5103e3aa914160f892c024df3e953 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <kact...@debian.org>
Date: Fri, 1 Mar 2019 10:39:33 +0000
Subject: [PATCH] Make /etc/rc.local conffile (Closes: #923485)

---
 debian/initscripts.postinst         |  4 ++++
 debian/initscripts.preinst          | 10 +++++++++-
 debian/src/initscripts/Makefile     |  1 +
 debian/src/initscripts/etc/rc.local | 12 ++++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 debian/src/initscripts/etc/rc.local

diff --git a/debian/initscripts.postinst b/debian/initscripts.postinst
index ad0eb4d0..1b23e3aa 100755
--- a/debian/initscripts.postinst
+++ b/debian/initscripts.postinst
@@ -18,6 +18,10 @@ case "$1" in
        ;;
 esac
 
+if [ -f /etc/rc.local.dpkg-old ] ; then
+       mv /etc/rc.local.dpkg-old /etc/rc.local
+fi
+
 umask 022
 
 # In 2.88dsf-23 the "mountoverflowtmp" script was dropped entirely.
diff --git a/debian/initscripts.preinst b/debian/initscripts.preinst
index 6c11ca13..698be29a 100755
--- a/debian/initscripts.preinst
+++ b/debian/initscripts.preinst
@@ -49,4 +49,12 @@ esac
 
 #DEBHELPER#
 
-:
+case $1 in
+(install|upgrade)
+       if dpkg --compare-versions "$2" lt '2.94-2' ; then
+               if [ -f /etc/rc.local ] ; then
+                       mv /etc/rc.local /etc/rc.local.dpkg-old
+               fi
+       fi
+       ;;
+esac
diff --git a/debian/src/initscripts/Makefile b/debian/src/initscripts/Makefile
index 995ac89c..79294915 100644
--- a/debian/src/initscripts/Makefile
+++ b/debian/src/initscripts/Makefile
@@ -27,6 +27,7 @@ install:
        find $(DESTDIR)/lib -type d -name .svn  -print0 |xargs -r0 rm -r
        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 644 $(DESTDIR)/lib/init/*.sh
        chmod -R g-w $(DESTDIR)
        chown -R root:root $(DESTDIR)
diff --git a/debian/src/initscripts/etc/rc.local 
b/debian/src/initscripts/etc/rc.local
new file mode 100644
index 00000000..972c0672
--- /dev/null
+++ b/debian/src/initscripts/etc/rc.local
@@ -0,0 +1,12 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# 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.
+
+[ -d /etc/boot.d ] && run-parts /etc/boot.d

-- 
        Note, that I send and fetch email in batch, once every 24 hours.
                 If matter is urgent, try https://t.me/kaction
                                                                             --

Reply via email to