aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-daemons/postfix/files/check_hostname.sh
blob: 37a0dd088cf9c9132b78d92568d194dd8803c967 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#! /bin/sh

HOSTNAME=$(/bin/hostname)

if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ]; then
	# If hostname is invalid, and myhostname not existed in main.cf
	/usr/sbin/postconf -h "myhostname" 2>/dev/null
	if [ $? -ne 0 ]; then
		# Set "localhost" to main.cf
		/usr/sbin/postconf -e "myhostname=localhost"
	fi
fi