#!/bin/sh

MODULES="wpa"

start() {
	printf 'Starting %s:' "$MODULES"
	sh -c  'sleep 5 ; /usr/sbin/wpa_supplicant -i wlan0 -B -c /etc/wpa_supplicant.conf' &> /dev/null &
	echo ' OK'
}

stop() {
	printf 'Stopping %s: ' "$MODULES"
	killall wpa_supplicant
	echo 'OK'
}

restart() {
	stop
	sleep 1
	start
}

case "$1" in
	start|stop|restart)
		"$1";;
	reload)
		# Restart, since there is no true "reload" feature.
		restart;;
	*)
		echo "Usage: $0 {start|stop|restart|reload}"
		exit 1
esac

exit $?
