{
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
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]) ;;
try_hostname()
{
+ [ "$hostname" = "$1" ] && return 0
if valid_domainname "$1"; then
+ syslog info "Setting hostname: $1"
_hostname "$1"
else
syslog err "Invalid hostname: $1"