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