1 # Set the hostname from DHCP data if required 2 3 need_hostname() 4 { 5 local hostname="" 6 7 case "$force_hostname" in 8 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) ;; 9 *) hostname="$(hostname)";; 10 esac 11 case "$hostname" in 12 ""|"(none)"|localhost|localhost.localdomain) 13 [ -n "$new_host_name" -o -n "$new_fqdn_name" ];; 14 "$old_host_name"|"$old_fqdn_name") 15 true;; 16 *) 17 false;; 18 esac 19 } 20 21 set_hostname() 22 { 23 if need_hostname; then 24 if [ -n "$new_host_name" ]; then 25 hostname "$new_host_name" 26 elif [ -n "$new_fqdn_name" ]; then 27 hostname "$new_fqdn_name" 28 fi 29 fi 30 } 31 32 if $if_up; then 33 set_hostname 34 fi 35