summaryrefslogtreecommitdiffstats
path: root/modules.d/slx-network/hooks/activate-bootif-dhcp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/slx-network/hooks/activate-bootif-dhcp.sh')
-rw-r--r--modules.d/slx-network/hooks/activate-bootif-dhcp.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/modules.d/slx-network/hooks/activate-bootif-dhcp.sh b/modules.d/slx-network/hooks/activate-bootif-dhcp.sh
new file mode 100644
index 00000000..f5345c61
--- /dev/null
+++ b/modules.d/slx-network/hooks/activate-bootif-dhcp.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# This script configures the udhcpc-based DHCP service for
+# within stage4, unless specifically disabled by SLX_STAGE4_DHCP
+
+. /etc/openslx
+[ -n "$SLX_STAGE4_DHCP" ] || exit 0
+
+for script in setup-bootif-network udhcpc-trigger; do
+ if [ -e "${NEWROOT}/opt/openslx/scripts/${script}" ]; then
+ mv "${NEWROOT}/opt/openslx/scripts/${script}"{,.stage4}
+ fi
+ cp -f "/opt/openslx/scripts/${script}.stage4" \
+ "${NEWROOT}/opt/openslx/scripts/${script}"
+done
+
+# copy udhcpc@ systemd service, backup existing ones for debugging
+mkdir -p "${NEWROOT}/etc/systemd/system"
+cp -f "/opt/openslx/services/udhcpc-bootif.service" "${NEWROOT}/etc/systemd/system"
+
+# it requires /run/network
+echo 'd /run/network 0755 root root' > "${NEWROOT}/etc/tmpfiles.d/network.conf"
+
+# activate it for the bridge or the physical interface if not bridged
+systemctl --quiet --root "$NEWROOT" enable "udhcpc-bootif"
+