summarylogtreecommitdiffstats
path: root/wifi.hook
blob: 2813af1457938010885eaedd00429eaa95f9e230 (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
#!/usr/bin/ash

run_hook ()
{
	# sleep a couple of seconds so wlan0 is setup by kernel
	sleep 3

    echo "Starting wifi"

	# set wlan0 to up
	ip link set wlan0 up

	# assocciate with wifi network
	wpa_supplicant -B -D nl80211,wext -i wlan0 -c /etc/wpa_supplicant/initcpio.conf

	# sleep a couple of seconds so that wpa_supplicant finishes connecting
	sleep 5

	# wlan0 should now be connected and ready to be assigned an ip by the net hook
}

run_cleanuphook ()
{
	# kill wpa_supplicant running in the background
	killall wpa_supplicant

	# set wlan0 link down
	ip link set wlan0 down

	# wlan0 should now be fully disconnected from the wifi network
}