1#!/bin/sh 2# 3# SPDX-License-Identifier: GPL-2.0-only 4# 5 6### BEGIN INIT INFO 7# Provides: hostname 8# Required-Start: 9# Required-Stop: 10# Default-Start: S 11# Default-Stop: 12# Short-Description: Set hostname based on /etc/hostname 13### END INIT INFO 14HOSTNAME=$(/bin/hostname) 15 16hostname -b -F /etc/hostname 2> /dev/null 17if [ $? -eq 0 ]; then 18 exit 19fi 20 21# Busybox hostname doesn't support -b so we need implement it on our own 22if [ -f /etc/hostname ];then 23 hostname `cat /etc/hostname` 24elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; then 25 hostname localhost 26fi 27