[arch-projects] [PATCH 1/7] config: add /etc/hostname support

Dave Reisner d at falconindy.com
Wed Oct 26 19:44:34 EDT 2011


On Thu, Oct 27, 2011 at 01:38:27AM +0200, Tom Gundersen wrote:
> If /etc/hostname is non-empty its contents is assumed to be the hostname.
> This takes precedence over HOSTNAME in rc.conf.
> 
> Signed-off-by: Tom Gundersen <teg at jklm.no>
> ---
>  rc.sysinit |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/rc.sysinit b/rc.sysinit
> index dffea4d..3e5fec9 100755
> --- a/rc.sysinit
> +++ b/rc.sysinit
> @@ -232,6 +232,9 @@ RANDOM_SEED=/var/lib/misc/random-seed
>  # Remove leftover files
>  remove_leftover
>  
> +if [[ -s /etc/hostname ]]; then
> +	HOSTNAME=$(cat /etc/hostname)

No need to fork. This should be a one line file.

read -r HOSTNAME < /etc/hostname

> +fi
>  if [[ $HOSTNAME ]]; then
>  	stat_busy "Setting Hostname: $HOSTNAME"
>  	echo "$HOSTNAME" >| /proc/sys/kernel/hostname && stat_done || stat_fail
> -- 
> 1.7.7.1
> 


More information about the arch-projects mailing list