From: Roy Marples Date: Mon, 27 Feb 2017 22:06:11 +0000 (+0000) Subject: If a new hostname is set, log it. X-Git-Tag: v7.0.0-beta1~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bf6c7b410f40996d44e63e6bcf10f93da664daa;p=thirdparty%2Fdhcpcd.git If a new hostname is set, log it. --- diff --git a/dhcpcd-hooks/30-hostname b/dhcpcd-hooks/30-hostname index eea6a5ce..44c2ecdc 100644 --- a/dhcpcd-hooks/30-hostname +++ b/dhcpcd-hooks/30-hostname @@ -20,7 +20,7 @@ _hostname() { local name= - if [ -z "$1" ]; then + if [ -z "${1+x}" ]; then if type hostname >/dev/null 2>&1; then hostname elif [ -r /proc/sys/kernel/hostname ]; then @@ -53,17 +53,18 @@ _hostname() need_hostname() { - local hostname hfqdn=false hshort=false - - case "$force_hostname" in - [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;; - esac + local hfqdn=false hshort=false + # Always load the hostname variable for future use hostname="$(_hostname)" case "$hostname" in ""|"(none)"|localhost|localhost.localdomain) return 0;; esac - + + case "$force_hostname" in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;; + esac + case "$hostname_fqdn" in [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;; ""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;; @@ -100,7 +101,9 @@ need_hostname() try_hostname() { + [ "$hostname" = "$1" ] && return 0 if valid_domainname "$1"; then + syslog info "Setting hostname: $1" _hostname "$1" else syslog err "Invalid hostname: $1"