#!/bin/sh

CMD=$1

case $CMD in
startup)
	echo "$0: startup received"
	DEVICE=eth0
	cardctl scheme CardResume
	killall dhcpcd
	ifconfig $DEVICE up
	wlanctl-ng $DEVICE lnxreq_autojoin "ssid=" authtype=opensystem
	ifconfig $DEVICE promisc
	wlanctl-ng $DEVICE lnxreq_wlansniff channel=6 enable=true
	;;

shutdown)
	echo "$0: shutdown received"
	ifconfig eth0 -promisc
	wlanctl-ng eth0 lnxreq_wlansniff channel=6 enable=false
	cardctl scheme default
	;;

hopper_type)
	echo "SCRIPT"
	;;

start_hopper)
	;;

stop_hopper)
	;;

set_channel)
	CHANNEL=$2
	echo "$0: set_channel received ($CHANNEL)"
	if [ -z "$CHANNEL" ]; then
		echo "$0: error: missing channel number"
		exit 1
	fi
	wlanctl-ng eth0 lnxreq_wlansniff channel=$CHANNEL enable=true
	;;

*)
	exit 1
	;;
esac

