On Thu, Oct 27, 2011 at 7:44 AM, Dave Reisner <[email protected]> wrote: > 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 <[email protected]> >> --- >> 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 >
If /etc/hostname does not end with a newline, `read' will return 1. Not sure if it matters here, but worth mentioning. How about, 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 >> >
