Skip to content
Snippets Groups Projects
hostname.sh 613 B
Newer Older
#!/bin/sh
### BEGIN INIT INFO
# Provides:          hostname
# Required-Start:
# Required-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Set hostname based on /etc/hostname
### END INIT INFO
HOSTNAME=$(/bin/hostname)

# Use gateway_hostaname if avaiable, if not use hostname file
if [ -f /etc/hostname ]; then
    if [ -f /usr/bin/gateway_hostname ]; then
        hostname `/usr/bin/gateway_hostname`
    else
        hostname `cat /etc/hostname`
    fi
elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; then
    hostname localhost