21
21
CONFIG="$MANDOSNETHOOKDIR/wireless.conf"
24
grep -liFe "$1" /sys/class/net/*/address \
25
| sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
24
29
if [ -e "$CONFIG" ]; then
30
interfaces="`env|sed -n -e 's/^\(MODULE\|IPADDRS\|ROUTES\|WPA_DRIVER\)_\([^=]*\)=.*/\2/p' \"$CONFIG\" |sort -u`"
35
ifkeys=`env | sed -n -e 's/^ADDRESS_\([^=]*\)=.*/\1/p' "$CONFIG" \
32
38
# Exit if DEVICE is set and is not any of the wireless interfaces
33
39
if [ -n "$DEVICE" ]; then
35
for IF in $interfaces; do
36
if [ "$IF" = "$DEVICE" ]; then
41
for KEY in $ifkeys; do
42
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
43
INTERFACE=`addrtoif "$ADDRESS"`
44
if [ "$INTERFACE" = "$DEVICE" ]; then
67
75
mkdir -m u=rwx,go= -p "$CTRLDIR"
68
76
"$wpa_supplicant" -B -g "$CTRL" -p "$CTRLDIR" $WPAS_OPTIONS
69
for INTERFACE in $interfaces; do
70
DRIVER=`eval 'echo "$WPA_DRIVER_'"$INTERFACE"\"`
71
DELAY=`eval 'echo "$DELAY_'"$INTERFACE"\"`
77
for KEY in $ifkeys; do
78
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
79
INTERFACE=`addrtoif "$ADDRESS"`
80
DRIVER=`eval 'echo "$WPA_DRIVER_'"$KEY"\"`
81
IFDELAY=`eval 'echo "$DELAY_'"$KEY"\"`
72
82
"$wpa_cli" -g "$CTRL" interface_add "$INTERFACE" "" \
73
83
"${DRIVER:-wext}" "$CTRLDIR" > /dev/null \
75
NETWORK=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" add_network`
76
eval wpa_interface_"$INTERFACE"
85
NETWORK=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" \
87
eval wpa_interface_"$KEY"
77
88
"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" enable_network \
78
89
"$NETWORK" | sed -e '/^OK$/d'
79
( sleep "${DELAY:-$DELAY}" || : ) &
90
sleep "${IFDELAY:-$DELAY}" &
82
kill -0 $sleep || break
83
STATE=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" status | sed -n -e 's/^wpa_state=//p'`
93
kill -0 $sleep 2>/dev/null || break
94
STATE=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" \
95
status | sed -n -e 's/^wpa_state=//p'`
84
96
if [ "$STATE" = COMPLETED ]; then
98
kill -0 $sleep 2>/dev/null || break 2
99
UP=`cat /sys/class/net/"$INTERFACE"/operstate`
100
if [ "$UP" = up ]; then
101
kill $sleep 2>/dev/null
91
IPADDRS=`eval 'echo "$IPADDRS_'"$INTERFACE"\"`
110
IPADDRS=`eval 'echo "$IPADDRS_'"$KEY"\"`
92
111
if [ -n "$IPADDRS" ]; then
93
112
if [ "$IPADDRS" = dhcp ]; then
94
113
ipconfig -c dhcp -d "$INTERFACE" || :
111
130
"$wpa_cli" -g "$CTRL" terminate 2>&1 | sed -e '/^OK$/d'
112
for INTERFACE in $interfaces; do
131
for KEY in $ifkeys; do
132
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
133
INTERFACE=`addrtoif "$ADDRESS"`
113
134
"$ip" addr show scope global permanent dev "$INTERFACE" \
114
135
| while read type addr rest; do