On Tue, 17 Jan 2017 08:57:22 +0100 Petter Reinholdtsen <[email protected]>
wrote:
> 
> Good.  Was there any leftover processes after the setup?  The purpose of
> policy-rc.d is to not leave any stray processes behind. :)
> 

In that case, I would suggest to modify setup, but keep a copy of the
original for running in chroots (setup-in-chroot). I'm attaching another
patch for this.
From 7d3ef8a49fc8bcfde6ba6e61c557dddb0a01e824 Mon Sep 17 00:00:00 2001
From: James Valleroy <[email protected]>
Date: Tue, 17 Jan 2017 05:36:54 -0500
Subject: [PATCH 2/2] Keep copy of original setup for running in chroots

---
 setup-in-chroot | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 setup-in-chroot

diff --git a/setup-in-chroot b/setup-in-chroot
new file mode 100755
index 0000000..0d268bd
--- /dev/null
+++ b/setup-in-chroot
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e  # Exit on error
+
+at_exit() {
+    if $policyd ; then
+       rm -f /usr/sbin/policy-rc.d
+    fi
+    policyd=false
+}
+
+# Make sure configuring packages do not start any services.  Also make
+# sure we remove policy-rc.d only if we created it.
+trap at_exit HUP INT TERM EXIT
+if [ ! -e /usr/sbin/policy-rc.d ] ; then
+    cat > /usr/sbin/policy-rc.d <<EOF
+#!/bin/sh
+exit 101
+EOF
+    chmod a+rx /usr/sbin/policy-rc.d
+    policyd=true
+else
+    policyd=false
+fi
+
+for f in /usr/lib/freedombox/setup.d/* ; do
+    echo "running $f"
+    $f
+done
-- 
2.11.0

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to