#!/bin/sh

# only for use as a "zcip" callback script
if [ "x$interface" = x ]
then
	exit 1
fi

# zcip should start on boot/resume and various media changes
case "$1" in
init)
	# for now, zcip requires the link to be already up,
	# and it drops links when they go down.  that isn't
	# the most robust model...
	exit 0
	;;
config)
	if [ "x$ip" = x ]
	then
		exit 1
	fi
	echo $ip > /config/zcip.ip
	/etc/init.d/S99octo stopoctoserve

	/sbin/ifconfig $interface $ip
	/sbin/route add default dev $interface
	/etc/init.d/S99octo startoctoserve
	exit 0
	;;
deconfig)
	if [ x$ip = x ]
	then
		exit 1
	fi
	/sbin/ifconfig $interface 0.0.0.0
	#exec ip address del dev $interface local $ip
	;;
esac
exit 1
