aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-run-hooks.in
blob: 7fd8b091dd1a6d3bdd89bda949577411f5cc9529 (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
#!/bin/sh
# dhcpcd client configuration script 

# Handy functions for our hooks to use
signature="# Generated by dhcpcd for ${interface}"
save_conf()
{
	if [ -f "$1" ]; then
		rm -f "$1"-pre."${interface}"
		mv -f "$1" "$1"-pre."${interface}"
	fi
}
restore_conf()
{
	[ -f "$1"-pre."${interface}" ] || return 1
	rm -f "$1"
	mv -f "$1"-pre."${interface}" "$1"
}

# We source each script into this one so that scripts run earlier can
# remove variables from the environment so later scripts don't see them.
# Thus, the user can create their dhcpcd.hook script to configure
# /etc/resolv.conf how they want and stop the system scripts ever updating it.
for hook in \
	@SYSCONFDIR@/dhcpcd.hook \
	@HOOKDIR@/*
do
	for skip in ${skip_hooks}; do
		case "${hook}" in
			"${skip}")			continue 2;;
			*/[0-9][0-9]"-${skip}")		continue 2;;
			*/[0-9][0-9]"-${skip}.sh")	continue 2;;
		esac
	done
	if [ -f "${hook}" ]; then
		. "${hook}"
	fi
done