aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks/30-hostname
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpcd-hooks/30-hostname')
-rw-r--r--dhcpcd-hooks/30-hostname26
1 files changed, 16 insertions, 10 deletions
diff --git a/dhcpcd-hooks/30-hostname b/dhcpcd-hooks/30-hostname
index b2e5fc8..87446fb 100644
--- a/dhcpcd-hooks/30-hostname
+++ b/dhcpcd-hooks/30-hostname
@@ -2,10 +2,16 @@
need_hostname()
{
- case "$(hostname)" in
+ 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}")
+ [ -n "$new_host_name" -o -n "$new_fqdn_name" ];;
+ "$old_host_name"|"$old_fqdn_name")
true;;
*)
false;;
@@ -15,14 +21,14 @@ need_hostname()
set_hostname()
{
if need_hostname; then
- if [ -n "${new_host_name}" ]; then
- hostname "${new_host_name}"
- else
- hostname "${new_fqdn_name}"
+ if [ -n "$new_host_name" ]; then
+ hostname "$new_host_name"
+ elif [ -n "$new_fqdn_name" ]; then
+ hostname "$new_fqdn_name"
fi
fi
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_hostname;;
-esac
+if $if_up; then
+ set_hostname
+fi