#!/bin/bash
#
# sdb4		Launch SD B4 setup and tools
#
# Author:	Francis Dupont <fdupont@isc.org>
#
# description: Launch SD B4 setup and tools
#

wanif=eth1

# See how we were called.
case "$1" in
  start)
	/usr/sbin/dhclient -6 -q -nw -D LL \
	-cf /etc/sdb4/confs/dhclient6.conf \
	-lf /tmp/lease6 $wanif
	;;
  stop)
	/etc/sdb4/scripts/shutdown6
	if [ -f /var/run/dnsmasq.pid ]; then
		kill -TERM `cat /var/run/dnsmasq.pid`
	fi
	if [ -f /var/run/dhclient6.pid ]; then
		kill -TERM `cat /var/run/dhclient6.pid`
	fi
	ifconfig $wanif 0.0.0.0 down
	;;
  status)
	state4=OFF
	state6=OFF
	if [ -f /tmp/sd-state4 ]; then
		. /tmp/sd-state4
		state4=$state
	fi
	if [ -f /tmp/sd-state6 ]; then
		. /tmp/sd-state6
		state6=$state
	fi
	echo "SDB4 state: IPv6" $state6 "- IPv4" $state4
	;;

  restart)
	$0 stop
	$0 start
	;;
  reload)
	$0 start
	exit $?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|reload|status}"
	exit 2
esac

exit 0
