#!/bin/sh

[ "${INTERFACE:0:4}" == "wlan" ] || exit 0

[ "$ACTION" == remove ] && {
	[ -f /tmp/run/hostapd-cli-$INTERFACE.pid ] || return
	kill "$(cat /tmp/run/hostapd-cli-$INTERFACE.pid)"
	rm /tmp/run/hostapd-cli-$INTERFACE.pid
	exit 0
}

[ "$ACTION" == add ] && {
	[ -f /tmp/run/hostapd-cli-$INTERFACE.pid ] && return
	touch /tmp/run/hostapd-cli-$INTERFACE.pid
	/usr/libexec/ratelimit-wait.sh $INTERFACE &
	exit 0
}
