/lib/dhcpcd/dhcpcd-hooks/30-hostname is in dhcpcd5 5.2.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # 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
}
try_hostname()
{
if valid_domainname "$1"; then
hostname "$1"
else
syslog err "Invalid hostname: $1"
fi
}
set_hostname()
{
if need_hostname; then
if [ -n "$new_host_name" ]; then
try_hostname "$new_host_name"
elif [ -n "$new_fqdn_name" ]; then
try_hostname "$new_fqdn_name"
fi
fi
}
if $if_up; then
set_hostname
fi
|