Skip to content

Instantly share code, notes, and snippets.

@Odyno
Created April 13, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Odyno/5c718b32b2cc00e576c9c44dae661192 to your computer and use it in GitHub Desktop.
Save Odyno/5c718b32b2cc00e576c9c44dae661192 to your computer and use it in GitHub Desktop.
Enable or Disable wifi in relation to eth connections
#!/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