#!/bin/sh
#
#	$Id: ifup-post,v 1.22 2000/11/16 15:58:55 baggins Exp $
#

run_up() { :; }

. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
. /etc/sysconfig/network-scripts/.functions

need_hostname
CONFIG=$1
source_config

# full device name as specified by user
FULLDEVNAME="$DEVICE"
# detect network device type (ie. dummy, eth for dummy0, eth0 ..)
DEVICETYPE=$(echo $DEVICE | awk ' { gsub(/[0-9]*$/,NUL); print $0 } ')
# real name of device (ie. is eth0 for eth0,eth0:1,eth0:alias)
DEVICE=$(echo $DEVICE | awk ' { gsub(/:.*$/,NUL); print $0 } ')

get_ppp_device_and_pid

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

# Set the queuing discipline
#    eg: sfq for better link sharing or teql0 for link equalizer
if [ -n "$QDISC" ] ; then
	tc qdisc add dev "$REALDEVICE" root $QDISC
fi

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

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 '/inet/ { 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
