xref: /dragonfly/etc/rc.d/wpa_supplicant (revision 3170ffd7)
1#!/bin/sh
2#
3# $FreeBSD: src/etc/rc.d/wpa_supplicant,v 1.2 2005/10/19 22:26:47 jkim Exp $
4#
5
6# PROVIDE: wpa_supplicant
7# REQUIRE: mountcritremote
8# KEYWORD: nojail nostart
9
10. /etc/rc.subr
11. /etc/network.subr
12
13name="wpa_supplicant"
14rcvar=
15command="/usr/sbin/${name}"
16conf_file="/etc/wpa_supplicant.conf"
17
18start_precmd="wpa_supplicant_precmd"
19wpa_supplicant_precmd()
20{
21	ifconfig $ifn up
22}
23start_postcmd="wpa_supplicant_postcmd"
24wpa_supplicant_postcmd()
25{
26	while ! ifconfig $ifn | grep -qw "status: associated"; do
27		sleep 1
28	done
29}
30
31ifn="$2"
32if [ -z "$ifn" ]; then
33	return 1
34fi
35
36is_ndis_interface()
37{
38	case `sysctl -n net.wlan.${1#wlan}.%parent 2>/dev/null` in
39		ndis*) true ;;
40		*) false ;;
41	esac
42}
43
44if is_ndis_interface ${ifn}; then
45	driver="ndis"
46else
47	driver="bsd"
48fi
49
50load_rc_config $name
51
52pid_file="/var/run/${name}/${ifn}.pid"
53command_args="-B -q -i $ifn -c $conf_file -D $driver -P $pid_file"
54required_files=$conf_file
55
56run_rc_command "$1"
57