git clone conn conn Log gph
Found at: gopher.r-36.net:70/scm/conn/file/examples/wifi/wlan0-action.sh.gph
twlan0-action.sh - conn - A script repository to manage connections in Linux.
---
twlan0-action.sh (987B)
---
1 #!/bin/sh
2
3 . /etc/conn/common.sh
4
5 WIFIDIR="${ETCDIR}/wifi"
6
7 interface="$1"
8 action="$2"
9 ssid="$3"
10 [ -z "$ssid" ] && ssid="$(getssid $interface)"
11
12 [ $LOGGING -eq 1 ] && \
13 logger -t "$interface-action" "Got request for $interface $ssid $action."
14
15 getscript() {
16 awk -F'\t' "/$1\$/ {print \$1}" ${WIFIDIR}/networks.tbl
17 }
18
19 if [ ! -z "$ssid" ];
20 then
21 case "$action" in
22 CONNECTED)
23 aps=$(getstates "wifi" $interface "$ssid")
24 if [ ! -z "$aps" ];
25 then
26 for i in "$aps":
27 do
28 issid="$(echo $i | awk -F'|' '{print $2}')"
29 $0 $interface DISCONNECTED "$issid"
30 done
31 fi
32
33 addstate "wifi" $interface "$ssid"
34 ;;
35 DISCONNECTED)
36 delstate "wifi" $interface "$ssid"
37 ;;
38 *)
39 exit 1;
40 ;;
41 esac
42
43 script="$(getscript "$ssid")"
44 if [ -n "$script" ];
45 then
46 cd ${WIFIDIR}/networks
47 ./$script $interface $action
48 exit $?
49 fi
50 fi
51
52 case "$action" in
53 CONNECTED)
54 startdhcp $interface
55 ;;
56 DISCONNECTED)
57 stopdhcp $interface
58 ;;
59 *)
60 exit 1;
61 ;;
62 esac
63
64 exit 0
65
.