#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
	start)
		stat_busy "Starting VDE"
		    vde_switch -tap tun -daemon && \
		    ifconfig tun 192.168.254.254 && \
		    chmod 777 /var/run/vde.ctl/ -R && \
		    add_daemon vde && \
		    stat_done || stat_fail
		;;
	stop)
		stat_busy "Stopping VDE"
		killall vde_switch >/dev/null && rm /var/run/vde.ctl/ -R && \
		    rm_daemon vde && stat_done || stat_fail
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "usage: $0 {start|stop|restart}"
esac
exit 0