Skip to content

Instantly share code, notes, and snippets.

@gld1982ltd
Last active December 19, 2015 18:59
Show Gist options
  • Save gld1982ltd/6002995 to your computer and use it in GitHub Desktop.
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.
#!/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