homelab/fighter/scripts/ip_change_notifier.sh

24 lines
416 B
Bash
Raw Permalink Normal View History

2023-11-22 17:10:16 -08:00
#!/bin/bash
source ./webhook_secrets.env
generate_post_data() {
cat <<EOF
{
"content": "IP Address Changed",
"embeds": [{
"title": "IP Address Changed",
"description": "New IP: $1",
"color": "45973"
}]
}
EOF
}
IP=$(curl ipinfo.io/ip)
if [ "$IP" != "$(cat ip.tmp)" ]; then
curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data $IP)" $discord_webhook
fi
echo $IP > ip.tmp