#!/bin/sh

interface=$1

if [ -z $interface ]
then
	echo "Please pass valid wlan interface"
	exit 1
fi

start-stop-daemon -K -x /usr/sbin/wpa_supplicant
rm -rf /var/run/wpa_supplicant

start-stop-daemon -K --oknodo -x /usr/sbin/hostapd
start-stop-daemon -K -x /usr/sbin/dnsmasq

# clear any cached hostapd configurations
rm -rf /var/run/hostapd

ifconfig $interface down

