From owner-freebsd-rc@FreeBSD.ORG Wed Feb 16 16:44:54 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 480531065672; Wed, 16 Feb 2011 16:44:54 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from ns1temp.jnielsen.net (ns1temp.jnielsen.net [69.55.230.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0FF918FC08; Wed, 16 Feb 2011 16:44:53 +0000 (UTC) Received: from jnielsen.socialserve.com ([12.249.176.26]) (authenticated bits=0) by ns1temp.jnielsen.net (8.14.3/8.14.3) with ESMTP id p1GGKYcu055519 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 16 Feb 2011 11:20:34 -0500 (EST) (envelope-from lists@jnielsen.net) From: John Nielsen Content-Type: multipart/mixed; boundary=Apple-Mail-7--409034666 Date: Wed, 16 Feb 2011 11:20:28 -0500 To: freebsd-rc@freebsd.org Message-Id: Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) X-DCC-STAT_FI_X86_64_VIRTUAL-Metrics: ns1temp.jnielsen.net; whitelist X-Virus-Scanned: clamav-milter 0.96.5 at ns1temp.jnielsen.net X-Virus-Status: Clean Subject: [patch] rc support for multiple hostapd instances X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2011 16:44:54 -0000 --Apple-Mail-7--409034666 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I've been tinkering with various wireless setups recently, one of which = required running WPA on two hostap virtual access points. I was = surprised to see that support for this is not already present in our rc = infrastructure. Running multiple instances of hostapd works just fine, = so I hacked together the following. It add support for a new rc variable = hostapd_conf_files, which defaults to only "/etc/hostapd.conf" but may = contain a list of files. An instance of hostapd is started for each file = in the list. For testing I have used hostapd_conf_files=3D"/etc/hostapd.conf /etc/hostapd2.conf" in /etc/rc.conf. Any suggestions or concerns? I would love to see this or something like = it committed. I have not yet written a patch for rc.conf.5 but would be = happy to. JN --Apple-Mail-7--409034666 Content-Disposition: attachment; filename=multi-hostap.patch Content-Type: application/octet-stream; name="multi-hostap.patch" Content-Transfer-Encoding: 7bit --- defaults/rc.conf.orig 2011-02-16 10:27:51.000000000 -0500 +++ defaults/rc.conf 2011-02-16 10:30:13.000000000 -0500 @@ -256,7 +256,8 @@ # profile3 uses default ppp_mode and ppp_nat ### Network daemon (miscellaneous) ### -hostapd_enable="NO" # Run hostap daemon. +hostapd_enable="NO" # Run hostap daemon(s). +hostapd_conf_files="/etc/hostapd.conf" # List of config files to start a daemon with. syslogd_enable="YES" # Run syslog daemon (or NO). syslogd_program="/usr/sbin/syslogd" # path to syslogd, if you want a different one. syslogd_flags="-s" # Flags to syslogd (if enabled). --- rc.d.norun/hostapd 2011-01-04 20:19:40.000000000 -0500 +++ rc.d/hostapd 2011-02-16 10:24:28.000000000 -0500 @@ -12,14 +12,17 @@ name="hostapd" command="/usr/sbin/${name}" rcvar=`set_rcvar` +load_rc_config ${name} -conf_file="/etc/${name}.conf" -pidfile="/var/run/${name}.pid" - -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" +for conf_file in ${hostapd_conf_files}; do + #conf_file="/etc/${name}.conf" + pidfile="/var/run/hostapd`echo ${conf_file} | sed -e "s/\//_/g"`.pid" + + command_args="-P ${pidfile} -B ${conf_file}" + required_files="${conf_file}" + + run_rc_command "$1" +done --Apple-Mail-7--409034666 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-7--409034666--