Skip to content

Commit e119607

Browse files
committed
Added dynu.com as dynamic DNS updater
Signed-off-by: Stefano Guandalini <stefano.guandalini@proton.ch>
1 parent 182f9bd commit e119607

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

bin/ncp/NETWORKING/dynuDNS.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# DynuDNS updater client installation on Raspbian
4+
#
5+
# Copyleft 2022 by Stefano Guandalini <guandalf _a_t_ protonmail _d_o_t_ com>
6+
# GPL licensed (see end of file) * Use at your own risk!
7+
#
8+
9+
10+
11+
install()
12+
{
13+
apt-get update
14+
apt-get install --no-install-recommends -y dnsutils
15+
}
16+
17+
configure()
18+
{
19+
local updateurl=https://api.dynu.com/nic/update
20+
local url="${updateurl}?hostname=${DOMAIN}&myipv6=${MYIPV6}&password=${PASSWORD}"
21+
22+
[[ $ACTIVE != "yes" ]] && {
23+
rm -f /etc/cron.d/dynuDNS
24+
service cron restart
25+
echo "dynuDNS client is disabled"
26+
return 0
27+
}
28+
29+
cat > /usr/local/bin/dynudns.sh <<EOF
30+
#!/bin/bash
31+
echo "DynuDNS client started"
32+
echo "${url}"
33+
registeredIP=\$(dig +short "$DOMAIN"|tail -n1)
34+
currentIP=\$(wget -q -O - http://checkip.dyndns.org|sed s/[^0-9.]//g)
35+
[ "\$currentIP" != "\$registeredIP" ] && {
36+
wget -q -O /dev/null "${url}"
37+
}
38+
echo "Registered IP: \$registeredIP | Current IP: \$currentIP"
39+
EOF
40+
chmod +744 /usr/local/bin/dynudns.sh
41+
42+
echo "*/${UPDATEINTERVAL} * * * * root /bin/bash /usr/local/bin/dynudns.sh" > /etc/cron.d/dynuDNS
43+
chmod 644 /etc/cron.d/dynuDNS
44+
service cron restart
45+
46+
set-nc-domain "$DOMAIN"
47+
48+
echo "DynuDNS client is enabled"
49+
}
50+
51+
# License
52+
#
53+
# This script is free software; you can redistribute it and/or modify it
54+
# under the terms of the GNU General Public License as published by
55+
# the Free Software Foundation; either version 2 of the License, or
56+
# (at your option) any later version.
57+
#
58+
# This script is distributed in the hope that it will be useful,
59+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
60+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+
# GNU General Public License for more details.
62+
#
63+
# You should have received a copy of the GNU General Public License
64+
# along with this script; if not, write to the
65+
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
66+
# Boston, MA 02111-1307 USA

etc/ncp-config.d/dynuDNS.cfg

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"id": "dynuDNS",
3+
"name": "Dynamic DNS from dynuDNS",
4+
"title": "dynuDNS",
5+
"description": "DynuDNS DynamicDNS service",
6+
"info": "Need account from https://www.dynu.com/",
7+
"infotitle": "",
8+
"params": [
9+
{
10+
"id": "ACTIVE",
11+
"name": "Active",
12+
"value": "no",
13+
"type": "bool"
14+
},
15+
{
16+
"id": "PASSWORD",
17+
"name": "Password (better UpdateIP hashed)",
18+
"value": "",
19+
"suggest": "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567"
20+
},
21+
{
22+
"id": "MYIPV6",
23+
"name": "IpV6 address",
24+
"value": "no",
25+
"suggest": "IpV6 address or 'no' not to update"
26+
},
27+
{
28+
"id": "DOMAIN",
29+
"name": "Domain",
30+
"value": "mynextcloud.example.com",
31+
"suggest": "mynextcloud.example.com"
32+
},
33+
{
34+
"id": "UPDATEINTERVAL",
35+
"name": "Update periodicity (in minutes)",
36+
"value": "30",
37+
"suggest": "30"
38+
}
39+
]
40+
}

0 commit comments

Comments
 (0)