From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-898517-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id B385B138330
	for <garchives@archives.gentoo.org>; Wed, 24 Aug 2016 18:49:17 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B117DE0B81;
	Wed, 24 Aug 2016 18:49:14 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 13792E0B82
	for <gentoo-commits@lists.gentoo.org>; Wed, 24 Aug 2016 18:49:13 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 931A0340997
	for <gentoo-commits@lists.gentoo.org>; Wed, 24 Aug 2016 18:49:12 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 3A9272453
	for <gentoo-commits@lists.gentoo.org>; Wed, 24 Aug 2016 18:49:10 +0000 (UTC)
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" <williamh@gentoo.org>
Message-ID: <1471976539.353bb9bc9a0ab3c6650d72d2ceb14c990762a2a0.williamh@OpenRC>
Subject: [gentoo-commits] proj/openrc:master commit in: init.d/
X-VCS-Repository: proj/openrc
X-VCS-Files: init.d/hostname.in
X-VCS-Directories: init.d/
X-VCS-Committer: williamh
X-VCS-Committer-Name: William Hubbs
X-VCS-Revision: 353bb9bc9a0ab3c6650d72d2ceb14c990762a2a0
X-VCS-Branch: master
Date: Wed, 24 Aug 2016 18:49:10 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 72a908a2-3c78-4ade-85b3-5cc0e3553036
X-Archives-Hash: 84438de0e78dba7bfd72a3aee237970c

commit:     353bb9bc9a0ab3c6650d72d2ceb14c990762a2a0
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Aug 23 18:22:19 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Aug 23 18:22:19 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=353bb9bc

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

 init.d/hostname.in | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/init.d/hostname.in b/init.d/hostname.in
index 21ed701..74866b4 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"
 }