Skip to content

Instantly share code, notes, and snippets.

@kchoudhu
Created September 7, 2017 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kchoudhu/9f7a0eb38722d82241518add921c3173 to your computer and use it in GitHub Desktop.
Save kchoudhu/9f7a0eb38722d82241518add921c3173 to your computer and use it in GitHub Desktop.
Allow hostapd(8) rc script to manage multiple access points
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: hostapd
# REQUIRE: mountcritremote
# KEYWORD: nojail shutdown
. /etc/rc.subr
name="hostapd"
desc="Authenticator for IEEE 802.11 networks"
command="/usr/sbin/${name}"
load_rc_config ${name}
if [ -n "$hostapd_ifaces" ]; then
nl_hostapd_ifaces=`(echo $hostapd_ifaces | tr '\s+' '\n')`
for iface in $nl_hostapd_ifaces
do
conf_file="/etc/${name}-${iface}.conf $conf_file"
done
pidfile="/var/run/${name}.pid"
else
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
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"
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment