All pastes #24638 Raw Edit

Mine

public text v1 · immutable
#24638 ·published 2005-10-04 22:11 UTC
rendered paste body
#!/bin/bash

interface='ppp0'
script=`basename $0`

# countach.com.ar
urls[0]='http://freedns.afraid.org/dynamic/update.php?'

cache='/var/cache/freedns-update.cache'

( ifconfig $interface &>/dev/null && test -w $cache ) || exit 0

newAddress=`ifconfig $interface | grep inet | sed 's/addr://g' | awk '{print($2)}'`
oldAddress=`head -1 $cache`

if [ "$newAddress" != "$oldAddress" ]
then
  echo -e "$script: Updating FreeDNS domains..."
  echo "$newAddress" > $cache
  for url in "${urls[@]}"
  do
    curl -s "$url" &>/dev/null
    sleep 1
  done
  echo "$script: Done."
fi