summaryrefslogtreecommitdiffstats
path: root/modules.d/slx-network/module-setup.sh
blob: 6e28ba1f0f52fc39db97c434c1ff001b4205fbf0 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
check() {
	[[ $mount_needs ]] && return 1

	if dracut_module_included "network" || dracut_module_included "systemd-networkd" ; then
		derror "This module conflicts with 'network' and 'systemd-networkd'!"
		return 1
	fi
	return 255
}

# called by dracut
depends() {
	echo "busybox kernel-network-modules"
}

# called by dracut
install() {
	# need initqueue to get a clean network start
	dracut_need_initqueue

		# install basic dns libs
	_arch=$(uname -m)
	inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*"

	# stage3 network scripts
	inst "${moddir}/scripts/udhcpc-trigger.stage3" "/usr/local/bin/udhcpc-trigger"

	# files for stage4, park them in /opt/openslx
	gcc -o "${initdir}/usr/local/bin/rdns" "${moddir}/rdns.c"
	inst "${moddir}/scripts/s3-setup-bootif-network.stage4" "/opt/openslx/scripts/s3-setup-bootif-network.stage4"
	inst "${moddir}/scripts/udhcpc-trigger.stage4" "/opt/openslx/scripts/udhcpc-trigger.stage4"
	inst "${moddir}/services/udhcpc-bootif-stage4.service" "/opt/openslx/services/udhcpc-bootif.service"

	# Parse IP config etc. from KCL
	_name="s3-parse-network-kcl"
	inst "$moddir/hooks/${_name}.sh" \
			"/usr/local/bin/${_name}.sh"
	inst_simple "${moddir}/services/${_name}.service" \
			"${systemdsystemunitdir}/${_name}.service"
	mkdir --parents \
			"${initdir}/${systemdsystemunitdir}/dracut-cmdline.service.requires"
	ln_r "${systemdsystemunitdir}/${_name}.service" \
			"${systemdsystemunitdir}/dracut-cmdline.service.requires/${_name}.service"
	# Setup bootif network: bridge, vlan, dhcp, ...
	_name="s3-setup-bootif-network"
	inst "$moddir/hooks/${_name}.sh" \
			"/usr/local/bin/${_name}.sh"
	inst_simple "${moddir}/services/${_name}.service" \
			"${systemdsystemunitdir}/${_name}.service"
	mkdir --parents \
			"${initdir}/${systemdsystemunitdir}/dracut-initqueue.service.wants"
	ln_r "${systemdsystemunitdir}/${_name}.service" \
			"${systemdsystemunitdir}/dracut-initqueue.service.wants/${_name}.service"
	# Copy files related to networking. Must be the very last thing before switchroot to
	# make sure nothing else tries to meddle with these after copying, e.g. slx-ssl.
	_name="s3-copy-network-files"
	inst "$moddir/hooks/${_name}.sh" \
			"/usr/local/bin/${_name}.sh"
	inst_simple "${moddir}/services/${_name}.service" \
			"${systemdsystemunitdir}/${_name}.service"
	mkdir --parents \
			"${initdir}/${systemdsystemunitdir}/dracut-pre-pivot.service.requires"
	ln_r "${systemdsystemunitdir}/${_name}.service" \
			"${systemdsystemunitdir}/dracut-pre-pivot.service.requires/${_name}.service"

	# hooks
	inst_hook pre-pivot 10 "${moddir}/hooks/configure-jumbo-frames.sh"
	# DO NOT TOUCH THIS
	inst_hook pre-pivot 60 "${moddir}/hooks/activate-stage4-dhcp.sh"
}