9 # Short-Description: Set hostname based on /etc/hostname
10 # Description: Read the machines hostname from /etc/hostname, and
11 # update the kernel value with this value. If
12 # /etc/hostname is empty, the current kernel value
13 # for hostname is used. If the kernel value is
14 # empty, the value 'localhost' is used.
20 . /lib/lsb/init-functions
23 [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
25 # Keep current name if /etc/hostname is missing.
26 [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)"
28 # And set it to 'localhost' if no setting was found
29 [ -z "$HOSTNAME" ] && HOSTNAME=localhost
31 [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'"
34 [ "$VERBOSE" != no ] && log_action_end_msg $ES
40 if [ "$HOSTNAME" ] ; then
51 restart|reload|force-reload)
52 echo "Error: argument '$1' not supported" >&2
63 echo "Usage: hostname.sh [start|stop]" >&2