#!/bin/sh

# This executes ifup/ifdown actions for connect/disconnect events from both
# netplugd and wpa_supplicant (wpa_cli -a).


dev="$1"
action="$2"

case "$action" in
in | up | CONNECTED)
	if [ -x /usr/local/sbin/ifup ]; then                               
		exec /usr/local/sbin/ifup $dev
	else
		echo "Please teach me how to bring up this interface!" 1>&2
	fi
	exit 1
	;;
out | down | DISCONNECTED)
	if [ -x /usr/local/sbin/ifdown ]; then                               
		exec /usr/local/sbin/ifdown $dev
	else
		echo "Please teach me how to bring down this interface!" 1>&2
	fi
	exit 1
	;;
*)
	exit 0
	;;
esac
