jrm@
Developer
- Thread Starter
- #26
DynDns now requires you to log in to your account from the web at least once a month, otherwise your free account will expire. Make a cron job for this script to automate this requirement.
Code:
#!/bin/sh
# This script requires ftp/wget and security/ca_root_nss.
# Login to DynDns to keep an account active.
# You have to add an entry like below to ~/.netrc.
# machine account.dyn.com login <username> password <pasword>
## Fill this in with the same value as <username> above. ####
USERNAME="m020543"
#############################################################
PROGNAME=dyndns_login
CERTFILE=/usr/local/share/certs/ca-root-nss.crt
COOKIE=`/usr/bin/mktemp /tmp/${PROGNAME}_cookie.XXXXXX`
OUTPUT=`/usr/bin/mktemp /tmp/${PROGNAME}_output.XXXXXX`
USERAGENT="Mozilla/5.0 (X11; FreeBSD amd64; rv:23.0) Gecko/20100101 Firefox/23.0"
MULTIFORM=`/usr/local/bin/wget --save-cookies "$COOKIE" --ca-certificate="$CERTFILE" -U "$USERAGENT" -O - -q https://account.dyn.com | /usr/bin/awk -F\' '/multiform/{ print $6 }'`
/usr/local/bin/wget --load-cookies "$COOKIE" --ca-certificate="$CERTFILE" -U "$USERAGENT" -O "$OUTPUT" -q --post-data="iov_id=&submit=Log+in&multiform=$MULTIFORM" https://account.dyn.com
if /usr/bin/grep -E "(Welcome|Hi).*$USERNAME" $OUTPUT > /dev/null 2>&1; then
echo DynDns login successful.
else
echo DynDns login failed.
FAILED="true"
fi
rm $COOKIE
rm $OUTPUT
if [ "$FAILED" = "true" ]; then
exit 1
fi