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