Init and fix ip_change_notifier script

This commit is contained in:
Joey Hafner 2023-11-22 17:10:16 -08:00
parent e0415f5ffa
commit 4d23714868
2 changed files with 26 additions and 1 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ jafner-net/config/ddns/ddclient/ddclient.conf
service-key.json
.terraform/
.terraform.lock.hcl
terraform/infrastructure/.tfvars
terraform/infrastructure/.tfvars
ip.tmp

View File

@ -0,0 +1,24 @@
#!/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