aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2016-08-23 13:22:19 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2016-08-23 13:22:19 -0500
commit353bb9bc9a0ab3c6650d72d2ceb14c990762a2a0 (patch)
treec1caa434ff83e9f8a77cb07904dad9e8ff6383bf
parent73cdf10f1f513be7b5dec4f1cc91e0c68cda689b (diff)
init.d/hostname: add support for /etc/hostname
-rw-r--r--init.d/hostname.in16
1 files changed, 11 insertions, 5 deletions
diff --git a/init.d/hostname.in b/init.d/hostname.in
index 21ed7019..74866b4c 100644
--- a/init.d/hostname.in
+++ b/init.d/hostname.in
@@ -17,10 +17,16 @@ depend() {
start()
{
- # HOSTNAME variable used to be defined in caps in conf.d/hostname.
- # It is also a magic variable in bash.
- hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
- ebegin "Setting hostname to $hostname"
- hostname "$hostname"
+ 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.
+ # 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"
}