21
21
CONFIG="$MANDOSNETHOOKDIR/wireless.conf"
24
grep -liFe "$1" /sys/class/net/*/address | sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
24
28
if [ -e "$CONFIG" ]; then
30
interfaces="`env|sed -n -e 's/^\(MODULE\|IPADDRS\|ROUTES\|WPA_DRIVER\)_\([^=]*\)=.*/\2/p' \"$CONFIG\" |sort -u`"
34
ifkeys="`env | sed -n -e 's/^ADDRESS_\([^=]*\)=.*/\1/p' \"$CONFIG\" | sort -u`"
32
36
# Exit if DEVICE is set and is not any of the wireless interfaces
33
37
if [ -n "$DEVICE" ]; then
35
for IF in $interfaces; do
36
if [ "$IF" = "$DEVICE" ]; then
39
for KEY in $ifkeys; do
40
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
41
INTERFACE=`addrtoif "$ADDRESS"`
42
if [ "$INTERFACE" = "$DEVICE" ]; then
67
73
mkdir -m u=rwx,go= -p "$CTRLDIR"
68
74
"$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"\"`
75
for KEY in $ifkeys; do
76
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
77
INTERFACE=`addrtoif "$ADDRESS"`
78
DRIVER=`eval 'echo "$WPA_DRIVER_'"$KEY"\"`
79
IFDELAY=`eval 'echo "$DELAY_'"$KEY"\"`
72
80
"$wpa_cli" -g "$CTRL" interface_add "$INTERFACE" "" \
73
81
"${DRIVER:-wext}" "$CTRLDIR" > /dev/null \
75
83
NETWORK=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" add_network`
76
eval wpa_interface_"$INTERFACE"
84
eval wpa_interface_"$KEY"
77
85
"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" enable_network \
78
86
"$NETWORK" | sed -e '/^OK$/d'
79
( sleep "${DELAY:-$DELAY}" || : ) &
87
sleep "${IFDELAY:-$DELAY}" &
82
kill -0 $sleep || break
90
kill -0 $sleep 2>/dev/null || break
83
91
STATE=`"$wpa_cli" -p "$CTRLDIR" -i "$INTERFACE" status | sed -n -e 's/^wpa_state=//p'`
84
92
if [ "$STATE" = COMPLETED ]; then
94
kill -0 $sleep 2>/dev/null || break 2
95
UP=`cat /sys/class/net/"$INTERFACE"/operstate`
96
if [ "$UP" = up ]; then
97
kill $sleep 2>/dev/null
91
IPADDRS=`eval 'echo "$IPADDRS_'"$INTERFACE"\"`
106
IPADDRS=`eval 'echo "$IPADDRS_'"$KEY"\"`
92
107
if [ -n "$IPADDRS" ]; then
93
108
if [ "$IPADDRS" = dhcp ]; then
94
109
ipconfig -c dhcp -d "$INTERFACE" || :
111
126
"$wpa_cli" -g "$CTRL" terminate 2>&1 | sed -e '/^OK$/d'
112
for INTERFACE in $interfaces; do
127
for KEY in $ifkeys; do
128
ADDRESS=`eval 'echo "$ADDRESS_'"$KEY"\"`
129
INTERFACE=`addrtoif "$ADDRESS"`
113
130
"$ip" addr show scope global permanent dev "$INTERFACE" \
114
131
| while read type addr rest; do