#!/bin/sh

# PROVIDE: hostapd
# REQUIRE: mountcritremote
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="hostapd"
desc="Authenticator for IEEE 802.11 networks"
#
# This portion of this rc.script is different from base.
case ${command} in
/usr/sbin/hostapd)	# Assume user does not want base hostapd because
			# user specified WITHOUT_WIRELESS in make.conf
			# and /etc/defaults/rc.conf contains this value.
			unset command;;
esac
command=${hostapd_program:-%%PREFIX%%/sbin/hostapd}
# End of differences from base. The rest of the file should remain the same.

ifn="$2"
if [ -z "$ifn" ]; then
	rcvar="hostapd_enable"
	conf_file="/etc/${name}.conf"
	pidfile="/var/run/${name}.pid"
else
	rcvar=
	conf_file="/etc/${name}-${ifn}.conf"
	pidfile="/var/run/${name}-${ifn}.pid"
fi

command_args="-P ${pidfile} -B ${conf_file}"
required_files="${conf_file}"
required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp"
extra_commands="reload"

load_rc_config ${name}
run_rc_command "$1"
