diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | e95877ecfa1170d77b1ec1f66752725cdda01b64 (patch) | |
tree | 81940f62fdf7891f127a1d1ffa712ac1ea1c4c5c /dhcpcd-hooks/30-hostname | |
download | external_dhcpcd-e95877ecfa1170d77b1ec1f66752725cdda01b64.zip external_dhcpcd-e95877ecfa1170d77b1ec1f66752725cdda01b64.tar.gz external_dhcpcd-e95877ecfa1170d77b1ec1f66752725cdda01b64.tar.bz2 |
Initial Contribution
Diffstat (limited to 'dhcpcd-hooks/30-hostname')
-rw-r--r-- | dhcpcd-hooks/30-hostname | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dhcpcd-hooks/30-hostname b/dhcpcd-hooks/30-hostname new file mode 100644 index 0000000..500ec0f --- /dev/null +++ b/dhcpcd-hooks/30-hostname @@ -0,0 +1,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 |