-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-zoneedit
executable file
·40 lines (34 loc) · 1 KB
/
update-zoneedit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
# Script to update a dynamic DNS entry managed by ZoneEdit.
#
# Usage:
# update-zoneedit [domain]
#
# (with environment variable ZONEEDIT_CREDENTIALS set to
# "username:password")
#
# If the 'domain' parameter is omitted, the current hostname (as returned
# by `hostname -f`) will be used.
#
# Make sure ZoneEdit credentials have been specified.
if [ "$ZONEEDIT_CREDENTIALS" == "" ]; then
echo "ZONEEDIT_CREDENTIALS environment variable not set"
exit 1
else
USERNAME=`echo $ZONEEDIT_CREDENTIALS | awk -F: '{ print $1 }'`
fi
# Use the domain given at the command line, or else our hostname.
if [ "$1" == "" ]; then
DOMAIN=`hostname`
else
DOMAIN="$1"
fi
# Print a message iff we're using an interactive shell.
if [ "$PS1" != "" ]; then
echo "Updating DNS record for '$DOMAIN' with ZoneEdit user '$USERNAME'"
fi
# Fetch the ZoneEdit Dynamic DNS update page!
HTTP_AUTH=basic:*:$ZONEEDIT_CREDENTIALS \
fetch -q -o - \
https://dynamic.zoneedit.com/auth/dynamic.html?host=$DOMAIN |\
grep -v "SUCCESS CODE="