Last active
December 19, 2015 18:59
-
-
Save gld1982ltd/6002995 to your computer and use it in GitHub Desktop.
Check if local ip is home or not. Executes command based location. Home or away.
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 | |
IP=$(ip route show dev eth0 | grep link | awk '{print $7}') | |
HOME='YOUR STATIC IP AT HOME' | |
function Home() { | |
echo "You are home."; } | |
function AwayFromHome() { | |
echo "You are away from home."; } | |
if [[ "$IP" == "$HOME" ]]; then | |
Home | |
else | |
AwayFromHome | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment