-
Notifications
You must be signed in to change notification settings - Fork 2
/
wifi
executable file
·50 lines (45 loc) · 927 Bytes
/
wifi
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
#!/bin/sh
case $(uname) in
FreeBSD)
case $(hostname) in
charmander)
interf=ath0
if ifconfig ath0 >/dev/null 2>&1; then
interf=ath0
fi
;;
oddish)
if ifconfig iwn0 >/dev/null 2>&1; then
interf=iwn0
fi
;;
esac
# Test for my USB wlan dongle but let it be overridden.
if [ -z "$interf" ] && ifconfig run0 >/dev/null 2>&1; then
interf=run0
fi
ifconfig wlan0 >/dev/null 2>&1 || \
( ifconfig wlan create wlandev $interf && ifconfig wlan0 up )
;;
Linux)
ifconfig wlan0 up
iwconfig wlan0 channel auto
;;
esac
wpapid=$(pgrep wpa_supplicant)
if [ -n "$wpapid" ]; then
echo "Killing wpa_supplicant"
kill $wpapid
else
sleep 1
fi
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
sleep 1
case $(uname) in
FreeBSD)
dhclient wlan0
;;
Linux)
dhcpcd wlan0
;;
esac