-
-
Save kuzyaka/eef7364fcc98323c1dee01c4ad9adeb6 to your computer and use it in GitHub Desktop.
Update script for dynv6.com to set your IPv4 address
This file contains 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 -e | |
# based on https://gist.github.com/pulsar256/42313fcb2d3ae805805f | |
# adopted for padavan firmware | |
hostname=$1 | |
v4_address=$2 | |
token=$3 | |
v4_file=$HOME/.${hostname}.dynv6.addr4 | |
[ -e $v4_file ] && old=`cat $v4_file` | |
if [ -z "$hostname" -o -z "$token" ]; then | |
echo "Usage: token=<your-authentication-token> $0 your-name.dynv6.net [device]" | |
exit 1 | |
fi | |
if [ -e /usr/bin/curl ]; then | |
bin="curl -fsS" | |
elif [ -e /usr/bin/wget ]; then | |
bin="wget -O-" | |
else | |
echo "neither curl nor wget found" | |
exit 1 | |
fi | |
if [ -z "$v4_address" ]; then | |
echo "no IPv4 address found" | |
exit 1 | |
fi | |
current=$v4_address | |
if [ "$old" = "$current" ]; then | |
# when running via cron we do not need that kind of verbosity. | |
# echo "IPv4 address unchanged" | |
exit | |
fi | |
echo "new ipv4 address detected ${v4_address}, updating" | |
# send addresses to dynv6 | |
$bin "http://ipv4.dynv6.com/api/update?hostname=$hostname&ipv4=$v4_address&token=$token" | |
# save current address | |
echo $current > $v4_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment