#!/bin/sh

WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. network-functions

need_hostname
CONFIG=$1
source_config

DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
if echo "$DEVICE" |fgrep -qs :; then
    ISALIAS=yes
else
    ISALIAS=no
fi

if [ "$ISALIAS" = no ]; then
    /etc/sysconfig/network-scripts/ifup-aliases "$DEVICE"
fi

/etc/sysconfig/network-scripts/ifup-routes "$DEVICE"

# don't set hostname on ppp/slip connections
if [ "$2" = boot -a -n "$NEEDHOSTNAME" -a "${DEVICE}" != lo -a "${DEVICETYPE}" != ppp -a "${DEVICETYPE}" != slip ]; then
    IPADDR=`LANG= LC_ALL= ifconfig ${DEVICE} | fgrep 'inet addr' |
	    awk -F: '{ print $2 } ' | awk '{ print $1 }'`
    eval `/bin/ipcalc --silent --hostname ${IPADDR}`
	[ "$?" = 0 ] && set_hostname $HOSTNAME
fi

# Notify programs that have requested notification
do_netreport

POSTFIX_EXE=/usr/sbin/postfix
POSTFIX_CONFIG=/etc/postfix/main.cf
if [ -n "$SMTP_RELAYHOST" ] &&
   ! is_no "$SMTP_RELAYHOST" &&
   [ -x "$POSTFIX_EXE" -a -w "$POSTFIX_CONFIG" ] &&
   tr=`mktemp "$POSTFIX_CONFIG".XXXXXX`; then
   	if cat "$POSTFIX_CONFIG" >"$tr" &&
	   subst "s/^relayhost *=.*/relayhost = $SMTP_RELAYHOST/" "$tr"; then
		grep -qs '^relayhost *=' "$tr" || 
			echo "relayhost = $SMTP_RELAYHOST" >>"$tr"
		! cmp -s "$POSTFIX_CONFIG" "$tr" &&
		cp -pf "$POSTFIX_CONFIG" "$POSTFIX_CONFIG".save &&
		cat "$tr" >"$POSTFIX_CONFIG" &&
		"$POSTFIX_EXE" reload
	fi
	rm -f "$tr"
fi

IFUP_LOCAL=/usr/local/sbin/ifup-post-local
if [ -x "$IFUP_LOCAL" ]; then
    "$IFUP_LOCAL" "$DEVICE"
fi
:
