#!/bin/sh
#
#	$Id: ifup-ipx 6447 2005-10-16 19:26:11Z baggins $
#
# configures IPX on $1 if appropriate

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

PATH=/sbin:/usr/sbin:/bin:/usr/bin

if [ "$1" = "" ]; then
    nls "Usage: %s <device name>" "ifup-ipx" >&2
    exit 1
fi

if is_no "$IPX"; then
    exit 0
fi

if [ ! -x /sbin/ipx_interface ] ; then
    nls "%s is missing. Can't continue." "/sbin/ipx_interface"
    exit 1
fi

cd /etc/sysconfig/network-scripts

CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config

# set all major variables
setup_ip_param

# add ipx for all frame types
for frametype in '802.2' '802.2TR' '802.3' 'EtherII' 'SNAP'; do
    framename=$(echo $frametype | awk ' { gsub(/\./,"_"); print $0 } ')
    case $(eval echo $(echo \$`echo IPXACTIVE_$framename`)) in
	yes|true)
	    case $(eval echo $(echo \$`echo IPXPRIMARY_$framename`)) in
		yes|true) primary="-p" ;;
		*) primary= ;;
	    esac

	    ip link set $DEVICE up
	    /sbin/ipx_interface add $primary $DEVICE $frametype \
		$(eval echo $(echo \$`echo IPXNETNUM_$framename`))
	    ;;
    esac
done

exit 0

# This must be last line !
# vi:syntax=sh:ts=8:sw=4
