Commit a538d6fb authored by Yuanle Song's avatar Yuanle Song
Browse files

support user agent in config file.

parent ab6eaae1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ PASSWORD=
HOSTNAME=
# using printf syntax, with %s being the new IP.
UPDATE_URL="https://$USERNAME:$PASSWORD@members.dyndns.org/nic/update?hostname=$HOSTNAME&myip=%s&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
# If set, this will be used as user-agent header for the http client.
# USER_AGENT=

# send email to this mail address when there are errors.
# default is root@localhost
+8 −1
Original line number Diff line number Diff line
@@ -153,8 +153,15 @@ Delete $FATAL_ERROR_FILE when you cleared the issue."
		exit $BAD_IP_ADDRESS
	fi

	# do update
	URL=`printf $UPDATE_URL $MYIP`
	curl -s -o "$HTTP_RESPONSE" "$URL"

	if [ "$USER_AGENT" ]; then
		USER_AGENT_OPTION="-A '$USER_AGENT'"
	else
		USER_AGENT_OPTION=""
	fi
	curl -s -o "$HTTP_RESPONSE" "$USER_AGENT_OPTION" "$URL"
	# check curl EXIT CODES
	CURL_EXIT_CODE=$?
	case $CURL_EXIT_CODE in