#!/bin/sh
#
#  Pin to the specified ESSID.

[ "$WIFIROAMD_PINESSID" != 1 ] && exit 0

[ "$WIFIROAMD_VERBOSE_LEVEL" -gt 0 ] && \
		logger -t 'wifiroamd_pinessid' "Pinning to $WIFIROAMD_ESSID"

if [ "${WIFIROAMD_DEVICE#ath}" != "$WIFIROAMD_DEVICE" ]
then
	#  hack for Atheros, run iwconfig 10 seconds after this script exits
	[ "$WIFIROAMD_VERBOSE_LEVEL" -gt 0 ] && \
			logger -t wifiroamd_pinessid "Sleeping because Atheros detected"
	( sleep 10; iwconfig "$WIFIROAMD_DEVICE" essid "$WIFIROAMD_ESSID" ) &
else
	iwconfig "$WIFIROAMD_DEVICE" essid "$WIFIROAMD_ESSID"
fi
