#!/bin/sh
# configures IPX on $1 if appropriate

WITHOUT_RC_COMPAT=1

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

if [ -z "$1" ]; then
	msg_usage "${0##*/} <net-device>"
	exit 1
fi

IPX_INTERFACE=/sbin/ipx_interface
if [ ! -x "$IPX_INTERFACE" ]; then
	# cannot configure IPX with non-existant utilities
	exit 0
fi

. /etc/sysconfig/network

is_yes "$IPX" || exit 0

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

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

for frametype in 802.2 802.3 ETHERII SNAP ; do
    # Yes, this kind of evaluation is really necessary to do this.
    # Welcome to shell programming...  No, we were not smoking some
    # particularly good floppies while we wrote this.  :-)
    framename=$(echo $frametype | sed 's/\./_/')
    if is_yes "$(eval echo $(echo \$`echo IPXACTIVE_$framename`))"; then
	if is_yes "$(eval echo $(echo \$`echo IPXPRIMARY_$framename`))"; then
		primary=-p
	else
		primary=
	fi
	"$IPX_INTERFACE" add $primary $1 $frametype \
	  $(eval echo $(echo \$`echo IPXNETNUM_$framename`))
    fi
done

exit 0

