#!/bin/sh
# Bring IPX networking up or down.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin
[ -x /opt/sbin/ipx_configure -a -f /etc/ipx.conf ] || exit 0
echo $0

case "$1" in
    start)
	. /etc/ipx.conf
	[ -f /lib/modules/current/misc/ipx.o ] && insmod -k ipx
	[ -z "$IPX_NETNUM" ] && IPX_NETNUM=0
	[ -z "$IPX_NODENUM" ] && IPX_NODENUM=1
	autop=on;autoi=on;prim='-p'
	if [ "$IPX_NETNUM" != 0 ];then
		autop=off;prim=''
		ipx_internal_net add "$IPX_NETNUM" "$IPX_NODENUM"
	fi
	if [ -n "$IPX_DEVICE" -a -n "$IPX_FRAME" ];then
		autoi=off
		ipx_interface add "$prim" "$IPX_DEVICE" "$IPX_FRAME" $IPX_NETNUM
	fi
	[ -n "$IPX_SERVER_NETNUM" -a -n "IPX_SERVER_NODENUM" -a \
		"$IPX_NETNUM" != 0 ] && \
	 ipx_route add "$IPX_SERVER_NETNUM" "$IPX_NETNUM" "$IPX_SERVER_NODENUM"
	ipx_configure --auto_primary="$autop" --auto_interface="$autoi"
	;;
    stop)
	ipx_configure --auto_primary=off --auto_interface=off
	ipx_interface delall
	[ -f /lib/modules/current/misc/ipx.o ] && rmmod ipx
	;;
    *)
	echo "Usage: $0 {start|stop}"
	exit 1
	;;
esac
exit 0
