commit 7d0e5cfd4b4a25706a33614381e0e479c5176bd9
parent cafd140c4e2e48a5445feaeee07ce422cba8616d
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Sun, 15 Nov 2020 14:33:24 +0100
TODO: handle udev with runit
Diffstat:
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/TODO b/TODO
@@ -8,6 +8,7 @@ runit: cgroups support;
runit: disable/remove Debian's sysvinit stuff;
runit: implement an option to automatically install a DHCP client on scanned NIC at boot or 1st-time boot?
runit: normalize etc/log.run, etc/sv/udhcpc/run, etc/sv/getty-ttyX
+runit: udev support
kernel: verify both UEFI and legacy boot support;
kernel: Secure boot support?
kernel: improve system resilience by disabling overcommit
diff --git a/templates/generic/root/etc/runit/common b/templates/generic/root/etc/runit/common
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -e
+exec 2>&1
+
+# not using cut because ps prints a header, and option to
+# avoid that "feature" is not standard. Other alternative
+# would be to not print 1st line, but it would require 2
+# pipes (ps | tail | cut) and would be similarly random.
+SVNAME="$(ps -oargs $PPID | sed -n '/runsv/ s/runsv // p')"
diff --git a/templates/generic/root/etc/sv/udhcpc/run b/templates/generic/root/etc/sv/udhcpc/run
@@ -1,13 +1,11 @@
#!/bin/sh
-set -e
-exec 2>&1
+. /etc/runit/common
-# not using cut because ps prints a header, and option to
-# avoid that "feature" is not standard. Other alternative
-# would be to not print 1st line, but it would require 2
-# pipes (ps | tail | cut) and would be similarly random.
-IFACE="$(ps -oargs $PPID | sed -n '/runsv/ s/runsv // p')"
-echo "Starting dhcp client on $IFACE..."
+IFACE="$(echo ${SVNAME} | cut -f2 -d-)"
+test -n "$IFACE" || badconf "Unable to retrieve interface name from \"$SVNAME\""
+ip link show "$IFACE" > /dev/null || badconf "Unknown IFACE"
+
+echo "Starting udhcpc on $IFACE..."
exec udhcpc -i ${IFACE} -f -R -n