| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/bin/sh
- echo "Current time: $(date "+%Y-%m-%d %H:%M:%S")"
- ip_file="ip"
- new_ip=$(curl -s http://ipecho.net/plain)
- # Fallbacks
- if [ -z "$new_ip" ]; then
- new_ip=$(curl -s http://whatismyip.akamai.com)
- fi
- if [ -z "$new_ip" ]; then
- new_ip=$(curl -s http://icanhazip.com/)
- fi
- if [ -z "$new_ip" ]; then
- new_ip=$(curl -s https://tnx.nl/ip)
- fi
- if [ -z "$new_ip" ]; then
- echo "Empty IP !"
- exit 0
- fi
- if [ -f $ip_file ]; then
- ip=$(cat $ip_file)
- if [ "$ip" = "$new_ip" ]; then
- echo "Same ip: $ip"
- exit 0
- fi
- fi
- update=$(curl -s -X GET "https://ip4.ddnss.de/upd.php?key=c1eed0f30eaa1a599570f18def222738&host=metzner.myhome-server.de")
- if echo "$update" | grep -q "Updated 1 hostname"; then
- echo "DDNSS-IP changed to: $new_ip"
- echo "$new_ip" > $ip_file
- else
- printf "Update failed:\\n%s" "$update"
- exit 1
- fi
|