summaryrefslogtreecommitdiffstats
path: root/modules.d/slx-network/hooks/activate-bootif-dhcp.sh
blob: 28e80f48edd5c0ff26a6952291bcf1e29223f6df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#
# This script enables the udhcpc-based DHCP service for stage4,
# unless specifically disabled by 'SLX_STAGE4_DHCP="no"'.

. /etc/openslx

if [ "$SLX_STAGE4_DHCP" != "no" ]; then
	mkdir -p "${NEWROOT}/opt/openslx/scripts"
	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"
fi

: