summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/slx-network/hooks/copy-network-files.sh
blob: d1dd48d1b7e4ae6d93b2878f104fa4c518f8f8e5 (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
#!/bin/bash

type -p warn &> /dev/null || . /lib/dracut-lib.sh

if [ -n "$NEWROOT" ]; then
	# backup network configuration files found in stage4
	for file in /etc/{hostname,hosts,resolv.conf}; do
		if [ ! -e "$file" ]; then
			warn "Missing '$file' - won't move it to stage4. "
			continue
		fi
		if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then
			mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.stage4"
		fi
		cp -af "$file" "${NEWROOT}/etc"
	done
	# special handling for resolv.conf:
	# move it to /opt/openslx to detect we are managing it
	mkdir -p "${NEWROOT}/opt/openslx"
	mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf"
	ln -s "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf"

	# HACK: finally make sure we have rdns helper
	# This should be done more elegantly one day...
	rdns="$(type -p rdns)"
	if [ -n "$rdns" ]; then
		mkdir -p "${NEWROOT}/opt/openslx/bin"
		cp -f "$rdns" "${NEWROOT}/opt/openslx/bin"
	fi
fi
true