diff options
author | Peter | 2020-10-04 18:11:50 +0100 |
---|---|---|
committer | Peter | 2020-10-04 18:11:50 +0100 |
commit | d867f23a038d1c91e130e69670269c0d1d79605e (patch) | |
tree | 261c590d6a5ef5a7324ec84764febce1a628060e /.local | |
parent | 5a63f202271d2e30fa109adb9b013d038eda82ca (diff) | |
download | dotfiles-d867f23a038d1c91e130e69670269c0d1d79605e.tar.gz dotfiles-d867f23a038d1c91e130e69670269c0d1d79605e.tar.bz2 dotfiles-d867f23a038d1c91e130e69670269c0d1d79605e.zip |
Manual wifi connection script
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/wifi | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/.local/bin/wifi b/.local/bin/wifi new file mode 100755 index 0000000..aa6bd0d --- /dev/null +++ b/.local/bin/wifi @@ -0,0 +1,20 @@ +#!/bin/bash + +# root check +if [ "$EUID" -ne 0 ]; then echo "Please run as root" && exit; fi + +# variables +interface=$(ip a | awk -F": " '/wlp/ {print $2}') +runfile=/run/wpa_supplicant/$interface +ping_test=1.1.1.1 + +# runfile check +if [ -f "$runfile" ] ; then echo Removing Runfile && rm "$runfile" ; fi + +# make connection +wpa_supplicant -B -c "/etc/wpa_supplicant/wpa_supplicant.conf" -i "$interface" && dhcpcd "$interface" + +# ping test +while true; do sleep 0.8 && ping -c 1 "$ping_test" && printf "\nConnected!" && break; done + +exit |