summaryrefslogtreecommitdiff
path: root/helpers/lh_confignetwork
blob: 892020df23e87576e80c9faadd605524d5f8fe0d (plain)
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
#!/bin/sh

# lh_patchnetwork.sh <action>

# Packages which are manually installed inside the chroot are installed
# from the network. Therefore, we need to be able to resolv hosts.

case "${1}" in
	apply-hosts)
		# Save host lookup table
		if [ -f "${LIVE_CHROOT}"/etc/hosts ]
		then
			cp "${LIVE_CHROOT}"/etc/hosts \
				"${LIVE_CHROOT}"/etc/hosts.orig
		fi

		# Copy host lookup table
		if [ -f /etc/hosts ]
		then
			cp /etc/hosts "${LIVE_CHROOT}"/etc/hosts
		fi
		;;

	apply-resolv)
		# Save resolver configuration
		if [ -f "${LIVE_CHROOT}"/etc/resolv.conf ]
		then
			cp "${LIVE_CHROOT}"/etc/resolv.conf \
				"${LIVE_CHROOT}"/etc/resolv.conf.orig
		fi

		# Copy resolver configuration
		if [ -f /etc/resolv.conf ]
		then
			cp /etc/resolv.conf "${LIVE_CHROOT}"/etc/resolv.conf
		fi
		;;

	deapply-hosts)
		# Restore host lookup table
		if [ -f "${LIVE_CHROOT}"/etc/hosts.orig ]
		then
			mv "${LIVE_CHROOT}"/etc/hosts.orig \
				"${LIVE_CHROOT}"/etc/hosts
		else
			rm -f "${LIVE_CHROOT}"/etc/hosts
		fi
		;;

	deapply-resolv)
		# Restore resolver configuration
		if [ -f "${LIVE_CHROOT}"/etc/resolv.conf.orig ]
		then
			mv "${LIVE_CHROOT}"/etc/resolv.conf.orig \
				"${LIVE_CHROOT}"/etc/resolv.conf
		else
			rm -f "${LIVE_CHROOT}"/etc/resolv.conf
		fi
		;;
esac