#!/bin/sh
#
#	$Id: ifup-post,v 1.17 2000/03/27 16:07:52 misiek Exp $
#

run_up() { :; }

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

need_hostname
CONFIG=$1
source_config

# full device name as specified by user
FULLDEVNAME="$DEVICE"
# type of device for example "dummy" or "eth"
DEVICETYPE=`echo $FULLDEVNAME | sed "s/[0-9]*$//"`
# name of real device ie. eth0 when eth0,eth0:1,eth0:alias
DEVICE=`echo $FULLDEVNAME | sed 's/:.*//g'`

if echo "$FULLDEVNAME" | grep -q ':' ; then
	ISALIAS=yes
else
	ISALIAS=no
fi

/etc/sysconfig/network-scripts/ifup-routes ${FULLDEVNAME}

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

# don't set hostname on ppp/slip connections
if [ -n "$NEEDHOSTNAME" -a "${DEVICE}" != lo -a "${DEVICETYPE}" != "ppp" -a "${DEVICETYPE}" != "slip" ]; then
	IPADDR=`ip -f inet addr show dev ${DEVICE} label ${FULLDEVNAME} | 
		awk '{ print $2 }' |awk -F"/" '{ print $1 }'`
	eval `/bin/ipcalc --silent --hostname ${IPADDR}` && set_hostname $HOSTNAME
fi

# execute run_up() function (if available in device configuration file)
[ "$ISALIAS" = "no" ] && run_up

# Notify programs that have requested notification
do_netreport

exit 0
