Created
April 13, 2020 13:56
-
-
Save Odyno/5c718b32b2cc00e576c9c44dae661192 to your computer and use it in GitHub Desktop.
Enable or Disable wifi in relation to eth connections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get curret datetime | |
now=$(date) | |
echo "Start to check connection: $now" | |
/sbin/ifconfig eth0 | grep -q 'netmask' | |
# 0 is active, 1 is inactive | |
eth0Status=$? | |
/sbin/ifconfig wlan0 | grep -q 'netmask' | |
# 0 is active, 1 is inactive | |
wifiStatus=$? | |
if [ $eth0Status = 1 ] && [ $wifiStatus = 1 ]; then | |
echo "Enable Wifi" | |
/sbin/iwconfig wlan0 txpower auto | |
fi | |
if [ $eth0Status = 0 ] && [ $wifiStatus = 0 ]; then | |
echo "Disable Wifi" | |
/sbin/iwconfig wlan0 txpower off | |
fi | |
echo "Done the Check" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment