summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2007-02-10 13:13:32 +0000
committeryar <yar@FreeBSD.org>2007-02-10 13:13:32 +0000
commitd34d506d9148f6b55a04f491e61779d95c097ee2 (patch)
tree3efb1da3c0fb042d56400a8c515c276540dec6bc /etc
parentbeff484b06db62ab979eef64896d9416a74f4391 (diff)
downloadFreeBSD-src-d34d506d9148f6b55a04f491e61779d95c097ee2.zip
FreeBSD-src-d34d506d9148f6b55a04f491e61779d95c097ee2.tar.gz
Handle the case when the admin forgot to set $hostname,
which can happen in new installations: advise to set the variable and refer to rc.conf(5).
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/hostname11
1 files changed, 10 insertions, 1 deletions
diff --git a/etc/rc.d/hostname b/etc/rc.d/hostname
index 3db4e77..a18b29c 100644
--- a/etc/rc.d/hostname
+++ b/etc/rc.d/hostname
@@ -58,7 +58,16 @@ hostname_start()
fi
fi
- /bin/hostname ${hostname}
+ # Have we got a hostname yet?
+ #
+ if [ -z "${hostname}" ]; then
+ warn "\$hostname is not set -- see ${rcvar_manpage}."
+ return
+ fi
+
+ # All right, it is safe to invoke hostname(1) now.
+ #
+ /bin/hostname "${hostname}"
echo "Setting hostname: `hostname`."
}
OpenPOWER on IntegriCloud