#!/bin/sh
status=$(echo "$@" | sed 's/.*\(link ok\|no link\)/\1/')

case "$status" in
  "link ok")
  	echo "link up"

	if ! /sbin/ifconfig eth0 | grep -q UP
	then
		ifup eth0
	fi

	;;

  "no link")
  	echo "link down"

	if /sbin/ifconfig eth0 | grep -q UP
	then
		ifdown eth0
	fi
	;;

  *)
  	echo "Did not detect status."
	;;
esac
