-
Create the file at
/sbin/namecheapddns.sh
and make it executable (chmod 0755 /sbin/namecheapddns.sh
)(Why under
/sbin
? Merely following the guide described in/etc.defaults/ddns_provider.conf
, but you can put it anywhere you want and make it 0755.) -
Append the following content to
/etc.defaults/ddns_provider.conf
:[Namecheap] modulepath=/sbin/namecheapddns.sh queryurl=https://namecheap.com website=https://namecheap.com
Last active
June 6, 2022 03:38
-
-
Save cooniur/9e60cf113947ccdd5834782da8ad0128 to your computer and use it in GitHub Desktop.
Namecheap DDNS Module for Synology NAS 7.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (c) 2022 Tongliang Liu | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: | |
The above copyright notice and this permission notice shall be | |
included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Namespace DDNS Module (namecheapddns.sh) | |
# This script is released under MIT License (https://choosealicense.com/licenses/mit) | |
# ==== BEGIN MIT LICENSE ==== | |
# Copyright (c) 2022 Tongliang Liu | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, | |
# distribute, sublicense, and/or sell copies of the Software, and to | |
# permit persons to whom the Software is furnished to do so, subject to | |
# the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be | |
# included in all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
# ==== END MIT LICENSE ==== | |
# Synology DDNS service will assign the UI inputs to these parameters in the following order when calling module: | |
# ($1=username, $2=password, $3=hostname, $4=ip) | |
# | |
# The script will use `username` as the domain (like `yourdomain.com`), | |
# and `hostname` as the HOST you set in Namecheap DNS manager (like `www`). | |
DOMAIN="$1" | |
PASSWORD="$2" | |
HOST="$3" | |
IP="$4" | |
RES=$(curl -s "https://dynamicdns.park-your-domain.com/update?host=${HOST}&domain=${DOMAIN}&password=${PASSWORD}&ip=${IP}") | |
ERRCNT=$(echo $RES | sed -n "s/.*<ErrCount>\(.*\)<\/ErrCount>.*/\1/p") | |
# No error, updated successfully | |
if [[ $ERRCNT -eq 0 ]]; then | |
echo "good" | |
exit 0 | |
fi | |
# Error handling | |
RESNUM=$(sed -n "s/.*<ResponseNumber>\(.*\)<\/ResponseNumber>.*/\1/p" <<< "$RES") | |
ERR=$(sed -n "s/.*<Err1>\(.*\)<\/Err1>.*/\1/p" <<< "$RES") | |
case $RESNUM in | |
304156) echo "badauth" | |
;; | |
380091) echo "nohost" | |
;; | |
*) echo "911 ['${RESNUM}: ${ERR}']" | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment