#!/bin/sh
#
# $FreeBSD: ports/net/ipw-firmware/files/ipw.sh.in,v 1.8 2006/05/08 09:37:16 flz Exp $
#

# PROVIDE: %%DRIVERNAME%%
# REQUIRE: mountcritlocal
# BEFORE:  ipfilter
# KEYWORD: shutdown

# Add the following line to /etc/rc.conf to enable `%%DRIVERNAME%%':
#
# %%DRIVERNAME%%_enable="YES"
#

. "%%RC_SUBR%%"

name="%%DRIVERNAME%%"
rcvar=`set_rcvar`

start_cmd="%%DRIVERNAME%%_start_cmd"
stop_cmd="%%DRIVERNAME%%_stop_cmd"

load_rc_config "$name"
: ${%%DRIVERNAME%%_enable="NO"}
: ${%%DRIVERNAME%%_interfaces="%%DRIVERNAME%%0"}

command="%%PREFIX%%/sbin/%%DRIVERNAME%%control"

%%DRIVERNAME%%_start_cmd()
{
	echo -n "Starting %%DRIVERNAME%%"
	for i in ${%%DRIVERNAME%%_interfaces}; do
		eval _mode=\$%%DRIVERNAME%%_mode_${i}
		case ${_mode} in
		""|bss)
			eval _%%DRIVERNAME%%_file_${i}="%%DRIVERNAME%%.fw"
			;;
		ibss)
			eval _%%DRIVERNAME%%_file_${i}="%%DRIVERNAME%%-i.fw"
			;;
		monitor)
			eval _%%DRIVERNAME%%_file_${i}="%%DRIVERNAME%%-p.fw"
			;;
		*)
			echo "${_mode} - Possible values for %%DRIVERNAME%%_mode_${i} are bss|ibss|monitor."
			exit 1
			;;
		esac

		eval _file=\$_%%DRIVERNAME%%_file_${i}
		echo -n " [${i}:${_mode:=bss}]"
		${command} -i ${i} -f %%FWDIR%%/${_file}
	done
	echo "."
}

%%DRIVERNAME%%_stop_cmd()
{
	echo "Stopping %%DRIVERNAME%%."
	for i in ${%%DRIVERNAME%%_interfaces}; do
		${command} -i ${i} -k
	done
}

run_rc_command "$1"


syntax highlighted by Code2HTML, v. 0.9.1