blob: a582353ef5c8a78b76fd4af380d43bd7ee2de9b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#! /bin/bash
. /usr/lib/network/network
. /usr/lib/network/8021x
. /usr/lib/network/wireless
AUTOWIFI="/usr/sbin/wpa_actiond"
ACTION_SCRIPT="/usr/bin/netcfg-wpa_actiond-action"
case $1 in
help)
echo "netcfg-wpa_actiond <interface>"
echo "netcfg-wpa_actiond stop <interface>"
exit
;;
stop)
stop_wpa $2
kill $(cat "/var/run/wpa_actiond_${2}.pid")
if [[ -n "$RFKILL" ]]; then # Enable radio if necessary
set_rf_state "$interface" down || exit $?
fi
exit
;;
*)
interface=$1; shift
PIDFILE="/var/run/wpa_actiond_${interface}.pid"
EXTRA_AUTOWIFI_OPTIONS="$*"
;;
esac
if [[ -z $interface ]]; then
echo "No interface specified"
exit 1
fi
# Load interface specific config
[[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
if [[ -f "$CONN_DIR/interfaces/$interface" ]]; then
netcfg -i $interface
fi
if [[ -n "$RFKILL" ]]; then # Enable radio if necessary
set_rf_state "$interface" up || exit $?
fi
WPA_CONF="$(make_wpa_config_file $interface)"
for profile in $(list_profiles); do
echo $profile
(
load_profile $profile
[[ $CONNECTION != "wireless" ]] && exit 1
[[ $INTERFACE != $interface ]] && exit 1
# Exclude wpa-config, the wpa_conf is 'complete' and doesn't fit in this scheme
[[ $SECURITY == "wpa-config" ]] && exit 1
config=$(make_wpa_config)
echo -e "network={ \n$config \nid_str=\"$profile\" \n}" >> $WPA_CONF
)
done
[[ -z $WPA_DRIVER ]] && WPA_DRIVER="wext"
# Kill any existing wpa_supplicant on this interface
stop_wpa "$interface"
if start_wpa $interface $WPA_CONF $WPA_DRIVER $WPA_OPTS; then
if $AUTOWIFI -i ${interface} -P ${PIDFILE} -a ${ACTION_SCRIPT} ${EXTRA_AUTOWIFI_OPTIONS}; then
exit 0
fi
fi
exit 1
|