Skip to content

Instantly share code, notes, and snippets.

@gld1982ltd
Last active December 19, 2015 18:59
Show Gist options
  • Save gld1982ltd/6002811 to your computer and use it in GitHub Desktop.
Save gld1982ltd/6002811 to your computer and use it in GitHub Desktop.
This script defines the public IP of Home and then checks the current public IP. If the current IP matches Home's IP, then one command is ran. If not, another command is ran.
#!/bin/bash
#
# This script defines the public IP of Home and
# then checks the current public IP. If the current
# IP matches Home's IP, then one command is ran.
# If not, another command is ran.
# Public IP at home
HOME='YOUR HOME dedicated public IP address.'
IP=$(curl ifconfig.me/ip;)
if [[ "$IP" == "$HOME" ]]; then
echo "Home!"
else
echo "Away from Home!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment