29 lines
1016 B
Bash
29 lines
1016 B
Bash
#!/usr/bin/env bash
|
|
|
|
token_gotify=
|
|
|
|
dotenv () {
|
|
set -a
|
|
# shellcheck disable=SC1091
|
|
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! No token for gotify.${reset}"
|
|
set +a
|
|
}
|
|
|
|
send_gotify_notification() {
|
|
now=$(date +"%d-%m-%Y %T")
|
|
gotify_server="https://gotify.maboiteverte.fr"
|
|
TITLE="IP has changed on $host"
|
|
MESSAGE="**L'IP externe a changé:**\n\n - ancienne IP: $old_ip_externe\n - **nouvelle IP: $ip_externe**\n\n [^]: $now\n"
|
|
PRIORITY=8
|
|
URL="$gotify_server/message?token=$token_gotify&?format=markdown"
|
|
|
|
echo -e "Sending notification to $gotify_server ..."
|
|
|
|
curl -L -S -s --data '{"message": "'"${MESSAGE}"'", "title": "'"${TITLE}"'", "priority":'"${PRIORITY}"', "extras": {"client::display": {"contentType": "text/markdown"}}}' -H 'Content-Type: application/json' "$URL" > /dev/null
|
|
|
|
[ $? -eq 0 ] && echo -e "${greenbold}Gotify notification sent successfully !${reset}" || echo -e "${redbold}error sending Gotify notification !${reset}"
|
|
}
|
|
|
|
dotenv
|
|
|
|
send_gotify_notification |