aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks/30-hostname
blob: 500ec0f21c54490bd4bc6a345f139967a0d8ec76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Set the hostname from DHCP data if required

need_hostname()
{
	case "$(hostname)" in
		""|"(none)"|localhost)	[ -n "${new_host_name}" ];;
		"${old_host_name}") 	true;;
		*) 			false;;
	esac
}

set_hostname()
{
	if need_hostname; then
		hostname "${new_host_name}"
	fi
}

case "${reason}" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)	set_hostname;;
esac