Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ok () {
- echo -e '\e[32;1m[ OK ]\e[0m'
- }
- fail () {
- echo -e '\e31;1m[ Fail ]\e[0m'
- }
- connect () {
- echo -n 'Resetting interface... '
- ifconfig wlan0 down
- sleep 3
- ifconfig wlan0 up
- ok
- echo -n 'Connecting... '
- wpa_supplicant -Dwext -iwlan0 -B -c /home/gluk47/wpa_supplicant.conf || { fail; return 1; }
- ok
- echo -n 'Running dhclient... '
- if dhclient wlan0; then
- ok
- else
- fail
- return 1
- fi
- }
- connected () {
- ping -c1 8.8.8.8 &>/dev/null
- }
- setup_network () {
- date
- connected && { echo 'Already connected'; return 0; }
- connect
- connected && { echo Connected; return 0; }
- echo -n 'Reloading wifi module... '
- rmmod iwldvm
- rmmod iwlwifi
- sleep 1
- modprobe iwlwifi
- ok
- connect
- }
- while :; do
- connected || setup_network
- sleep 5
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement