init.d/hostname: add support for /etc/hostname
This commit is contained in:
parent
73cdf10f1f
commit
353bb9bc9a
@ -17,10 +17,16 @@ depend() {
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
|
local h source x
|
||||||
|
if [ -s @SYSCONFDIR@/hostname ] && [ -r @SYSCONFDIR@/hostname ]; then
|
||||||
|
read h x <@SYSCONFDIR@/hostname
|
||||||
|
source=" from @SYSCONFDIR@/hostname"
|
||||||
|
else
|
||||||
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
|
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
|
||||||
# It is also a magic variable in bash.
|
# It is also a magic variable in bash.
|
||||||
hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
|
h=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
|
||||||
ebegin "Setting hostname to $hostname"
|
fi
|
||||||
hostname "$hostname"
|
ebegin "Setting hostname to $h $source"
|
||||||
|
hostname "$h"
|
||||||
eend $? "Failed to set the hostname"
|
eend $? "Failed to set the hostname"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user