Created
October 11, 2021 18:37
-
-
Save danlopez/321458afbed68624d6098f8fa05d7cf7 to your computer and use it in GitHub Desktop.
check if IP address matches last know IP, do something if it doesn't.
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 current IP | |
ip_address=$(curl icanhazip.com) | |
echo $ip_address | |
# Check if IP Address matches last known IP | |
FILE=/home/pi/scripts/ip.txt | |
old_ip=$(cat $FILE) | |
if [[ "$old_ip" != "$ip_address" ]];then | |
echo "Run a script" | |
fi | |
echo $ip_address > $FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment