blob: 517d4192fb3a66d3800b4fc48bc83e584cb4a162 (
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
|
#!/bin/env bash
interface="";
function guess_wifi {
toAll="$1"
for i in `ls /sys/class/net/`; do
if [ -d "/sys/class/net/$i/wireless" ] ; then
interface="$i"
fi
done
if [ -z $interface ] ; then
echo $'No Wireless interface found\nExit'
if [ "$toAll" == "all" ] ; then
echo 'flushing all'
interface=all
else
exit 1
fi
fi
}
echo "$@ $*"
if [ "$1" == 'off' ] ; then
if [ -z "$2" ] ; then
interface="$2"
else
guess_wifi 'all'
fi
echo 'OFF'
sudo pkill -f dhcpcd
sudo pkill -f wpa_supplicant
sudo ip route flush via "$interface";
sudo pkill -f ssh
exit 0
elif [ -z "$1" ] ; then
guess_wifi ''
else
interface="$1"
fi
if [ -z "$2" ]
then
sudo wpa_supplicant -B "-i${interface}" -D wext -c/etc/wpa_supplicant/wpa_supplicant.conf
else
if [ -z "$3" ]
then
sudo iwconfig "${interface}" essid "$2"
else
sudo iwconfig "${interface}" ap "$3"
sudo iwconfig "${interface}" essid "$2"
fi
fi
sudo dhcpcd "${interface}"
|