init.d/hostname: add support for /etc/hostname

This commit is contained in:
William Hubbs 2016-08-23 13:22:19 -05:00
parent 73cdf10f1f
commit 353bb9bc9a

View File

@ -17,10 +17,16 @@ depend() {
start() start()
{ {
# HOSTNAME variable used to be defined in caps in conf.d/hostname. local h source x
# It is also a magic variable in bash. if [ -s @SYSCONFDIR@/hostname ] && [ -r @SYSCONFDIR@/hostname ]; then
hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive read h x <@SYSCONFDIR@/hostname
ebegin "Setting hostname to $hostname" source=" from @SYSCONFDIR@/hostname"
hostname "$hostname" else
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
# It is also a magic variable in bash.
h=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
fi
ebegin "Setting hostname to $h $source"
hostname "$h"
eend $? "Failed to set the hostname" eend $? "Failed to set the hostname"
} }