Created
June 15, 2017 00:42
-
-
Save metalefty/a6900f92606d4437255a8af7454cc133 to your computer and use it in GitHub Desktop.
prowl-ipaddr
This file contains hidden or 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/sh | |
| set -e | |
| PROWL_APIKEY= | |
| for IFACE in $@ | |
| do | |
| curl -s \ | |
| --retry 20 --retry-delay 3 \ | |
| https://api.prowlapp.com/publicapi/verify?apikey=${PROWL_APIKEY} > /dev/null | |
| IP4ADDR=$(ip -o -4 addr show dev ${IFACE} | awk -F '[ /]+' '/global/ {print $4}') | |
| IP6ADDR=$(ip -o -6 addr show dev ${IFACE} | awk -F '[ /]+' '/global/ {print $4}') | |
| if [ -z "${IP4ADDR}" -a -z "${IP6ADDR}" ]; then | |
| continue | |
| fi | |
| curl -vvv \ | |
| --retry 10 --retry-delay 1 \ | |
| -d apikey=${PROWL_APIKEY} \ | |
| -d application=$(hostname) \ | |
| -d "event=ip address" \ | |
| -d "description=host: $(hostname) | |
| iface: ${IFACE} | |
| IPv4: ${IP4ADDR} | |
| IPv6: ${IP6ADDR}" \ | |
| https://api.prowlapp.com/publicapi/add | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment