~alpine/aports

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[alpine-aports] [PATCH] main/openrc: fix hostname init for btrfs subvolumes

Details
Message ID
<1447551789-21436-1-git-send-email-developer@it-offshore.co.uk>
Sender timestamp
1447551789
DKIM signature
missing
Download raw message
Patch: +1 -5
Busybox hostname doesn't seem to work on btrfs subvolumes (the hostname is set as "?")

This shell oneliner sets the hostname as the first non blank line in /etc/hostname.
If /etc/hostname is empty or does not exist the hostname is set to localhost.
---
 main/openrc/hostname.initd | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/main/openrc/hostname.initd b/main/openrc/hostname.initd
index fdc7f0b..49098f4 100644
--- a/main/openrc/hostname.initd
+++ b/main/openrc/hostname.initd
@@ -7,11 +7,7 @@ depend() {
}

start() {
	if [ -f /etc/hostname ] ; then
		opts="-F /etc/hostname"
	else
		opts="localhost"
	fi
	opts="$(grep -v '^$' /etc/hostname)" 2>/dev/null || opts="localhost"
	ebegin "Setting hostname"
	hostname $opts
	eend $?
-- 
2.6.3



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20151115133948.44f43146@ncopa-laptop>
In-Reply-To
<1447551789-21436-1-git-send-email-developer@it-offshore.co.uk> (view parent)
Sender timestamp
1447591188
DKIM signature
missing
Download raw message
On Sun, 15 Nov 2015 01:43:09 +0000
Stuart Cardall <developer@it-offshore.co.uk> wrote:

> Busybox hostname doesn't seem to work on btrfs subvolumes (the hostname is set as "?")
> 
> This shell oneliner sets the hostname as the first non blank line in /etc/hostname.
> If /etc/hostname is empty or does not exist the hostname is set to localhost.

Does it set hostname if its nonempty?

Does it set hostname if its empty and filesystem is something else than
btrfs?

I wonder why this is specific for btrfs.

> ---
>  main/openrc/hostname.initd | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/main/openrc/hostname.initd b/main/openrc/hostname.initd
> index fdc7f0b..49098f4 100644
> --- a/main/openrc/hostname.initd
> +++ b/main/openrc/hostname.initd
> @@ -7,11 +7,7 @@ depend() {
>  }
>  
>  start() {
> -	if [ -f /etc/hostname ] ; then
> -		opts="-F /etc/hostname"
> -	else
> -		opts="localhost"
> -	fi
> +	opts="$(grep -v '^$' /etc/hostname)" 2>/dev/null || opts="localhost"
>  	ebegin "Setting hostname"
>  	hostname $opts
>  	eend $?

Why not:

if [ -s /etc/hostname ]; then
    opts="-F /etc/hostname"
else
    opts="localhost"
fi

-nc


---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)