Skip to content

Instantly share code, notes, and snippets.

@kuzyaka
Forked from pulsar256/dynv6_v4only.sh
Last active October 13, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuzyaka/eef7364fcc98323c1dee01c4ad9adeb6 to your computer and use it in GitHub Desktop.
Save kuzyaka/eef7364fcc98323c1dee01c4ad9adeb6 to your computer and use it in GitHub Desktop.
Update script for dynv6.com to set your IPv4 address
#!/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