# Set the hostname from DHCP data if required

need_hostname()
{
	local hostname=""

	case "$force_hostname" in
	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) ;;
	*) hostname="$(hostname)";;
	esac
	case "$hostname" in
	""|"(none)"|localhost|localhost.localdomain)
		[ -n "$new_host_name" -o -n "$new_fqdn_name" ];;
	"$old_host_name"|"$old_fqdn_name")
		true;;
	*)
		false;;
	esac
}

set_hostname()
{
	if need_hostname; then
		if [ -n "$new_host_name" ]; then
			hostname "$new_host_name"
		elif [ -n "$new_fqdn_name" ]; then
			hostname "$new_fqdn_name"
		fi
	fi
}

if $if_up; then
	set_hostname
fi