summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitroretro2020-01-04 01:34:04 +0200
committerNitroretro2020-01-04 01:34:04 +0200
commit8ead0c42fa302ac1a920581a1314c24c195412d8 (patch)
treedb56b6a6cef23b0c1fd1a5eb9caf65da4831a11b
downloadaur-8ead0c42fa302ac1a920581a1314c24c195412d8.tar.gz
Initial commit
-rw-r--r--.SRCINFO23
-rw-r--r--.gitignore9
-rw-r--r--PKGBUILD29
-rw-r--r--duckdns-ipv6.install3
-rw-r--r--duckdns.conf42
-rw-r--r--duckdns.service9
-rwxr-xr-xduckdns.sh60
-rw-r--r--duckdns.timer8
8 files changed, 183 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..b8574ffaa2d8
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,23 @@
+pkgbase = duckdns-ipv6
+ pkgdesc = Automatically update DuckDNS domains, with IPv6 support
+ pkgver = 1.0
+ pkgrel = 1
+ url = https://duckdns.org
+ install = duckdns-ipv6.install
+ arch = any
+ license = GPL3
+ depends = jq
+ provides = duckdns
+ conflicts = duckdns
+ backup = etc/duckdns.d/default
+ source = duckdns.conf
+ source = duckdns.sh
+ source = duckdns.service
+ source = duckdns.timer
+ sha512sums = e781a69a01a7b590a5435f123d118ef64a111b57440a72e3671f560b4f2afae72f9a28c1766b032c7586fa95ac8b3dc7ea68b861d68571fcd6b3cb09185b7f68
+ sha512sums = 9188d922ec4d3c01f83e9d3880f86e60988c566010e9ec188bb3b86bde76276c84e1e305347ac877e5ee864b5b0c5218a09f09c8021f7bdea1faa1a19f871204
+ sha512sums = c32206e50a0e29810dbd80fe2f17216ff1b204f0ca4542a18dd444da6eb67e411ee0aab64b31af74cb7b9b43d547a35bf4f76bc215bc409c2be2e002a72e7701
+ sha512sums = b786e208d40a52592f1f82995cc3c8e65296a107e0f72a51c8d58e58906e3e0a7140b75f0894fa20ce2f814dae0656fc29312100c91e0acc004543c9bac13930
+
+pkgname = duckdns-ipv6
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..3185d8cbe82d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*
+!duckdns.conf
+!duckdns.sh
+!duckdns.service
+!duckdns.timer
+!duckdns-ipv6.install
+!PKGBUILD
+!.gitignore
+!.SRCINFO
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..9fcac1051750
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,29 @@
+# Maintainer: Nitroretro <nitroretro@protonmail.com>
+
+pkgname=duckdns-ipv6
+pkgver=1.0
+pkgrel=1
+pkgdesc="Automatically update DuckDNS domains, with IPv6 support"
+arch=("any")
+url="https://duckdns.org"
+license=("GPL3")
+depends=("jq")
+provides=("duckdns")
+conflicts=("duckdns")
+backup=("etc/duckdns.d/default")
+install="${pkgname}.install"
+source=("duckdns.conf"
+ "duckdns.sh"
+ "duckdns.service"
+ "duckdns.timer")
+sha512sums=('e781a69a01a7b590a5435f123d118ef64a111b57440a72e3671f560b4f2afae72f9a28c1766b032c7586fa95ac8b3dc7ea68b861d68571fcd6b3cb09185b7f68'
+ '9188d922ec4d3c01f83e9d3880f86e60988c566010e9ec188bb3b86bde76276c84e1e305347ac877e5ee864b5b0c5218a09f09c8021f7bdea1faa1a19f871204'
+ 'c32206e50a0e29810dbd80fe2f17216ff1b204f0ca4542a18dd444da6eb67e411ee0aab64b31af74cb7b9b43d547a35bf4f76bc215bc409c2be2e002a72e7701'
+ 'b786e208d40a52592f1f82995cc3c8e65296a107e0f72a51c8d58e58906e3e0a7140b75f0894fa20ce2f814dae0656fc29312100c91e0acc004543c9bac13930')
+
+package() {
+ install -Dm600 duckdns.conf "${pkgdir}/etc/duckdns.d/default"
+ install -Dm755 duckdns.sh "${pkgdir}/usr/bin/duckdns"
+ install -Dm644 duckdns.service "${pkgdir}/usr/lib/systemd/system/duckdns.service"
+ install -Dm644 duckdns.timer "${pkgdir}/usr/lib/systemd/system/duckdns.timer"
+}
diff --git a/duckdns-ipv6.install b/duckdns-ipv6.install
new file mode 100644
index 000000000000..396d8964ab95
--- /dev/null
+++ b/duckdns-ipv6.install
@@ -0,0 +1,3 @@
+post_install() {
+ echo "Don't forget to edit /etc/duckdns.d/default in order to provide your domain names, token and IP address providers!"
+}
diff --git a/duckdns.conf b/duckdns.conf
new file mode 100644
index 000000000000..615b5f6e0bdb
--- /dev/null
+++ b/duckdns.conf
@@ -0,0 +1,42 @@
+####################################################################################
+# This is the configuration file for the duckdns script. #
+# This file is interpreted as POSIX shell. Using POSIX shell syntax is sufficient. #
+####################################################################################
+# You can have multiple configuration files. Simply create another file in /etc/duckdns.d and the script will use it.
+
+## ENABLE
+# You can run the script every 10 minutes by enabling and starting duckdns.timer:
+#systemctl enable duckdns.timer
+#systemctl start duckdns.timer
+
+# You can run the script once on boot-up by enabling duckdns.service:
+#systemctl enable duckdns.service
+
+## CONFIGURATION
+# One domain or comma-separated list of domains. This is only the subdomain part of it, without .duckdns.org.
+# For updating foo.duckdns.org: DOMAINS="foo"
+# For updating both foo.duckdns.org and bar.duckdns.org: DOMAINS="foo,bar"
+#DOMAINS="foo"
+
+# Your DuckDNS token.
+#TOKEN="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+
+### IPv4
+# Use an URL for getting the IPv4 address.
+IPV4_URL="https://api.ipify.org"
+
+# Hardcode the IPv4 address. This option takes precedence over IPV4_URL.
+#IPV4_ADDRESS="127.0.0.1"
+
+# If neither of the two options are set then DuckDNS will automatically detect the IPv4 address, unless any of the IPv6 options are set.
+# From https://www.duckdns.org/spec.jsp:
+# > ipv6 - OPTIONAL - a valid IPv6 address, if you specify this then the autodetection for ip is not used
+
+### IPv6
+# Use an URL for getting the IPv6 address.
+IPV6_URL="https://api6.ipify.org"
+
+# Hardcode the IPv6 address. This option takes precedence over IPV6_URL.
+#IPV6_ADDRESS="::1"
+
+# If neither of the two options are set then the IPv6 address won't be updated.
diff --git a/duckdns.service b/duckdns.service
new file mode 100644
index 000000000000..922e70aaf1fb
--- /dev/null
+++ b/duckdns.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Update DuckDNS domain addresses
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/duckdns
+
+[Install]
+WantedBy=network-online.target
diff --git a/duckdns.sh b/duckdns.sh
new file mode 100755
index 000000000000..81db1e6308c1
--- /dev/null
+++ b/duckdns.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+failed=0
+
+log() {
+ [ "$1" = "err" ] && failed=1
+ [ -n "$config_name" ] && message="$config_name: $2" || message="$2"
+ logger -t DuckDNS -p "daemon.$1" "$message"
+}
+
+url_encode() {
+ jq --null-input --raw-output --arg input "$1" '$input | @uri'
+}
+
+log info "Updating the DuckDNS domains..."
+for config_file in /etc/duckdns.d/*; do
+ unset -v DOMAINS TOKEN IPV4_URL IPV4_ADDRESS IPV6_URL IPV6_ADDRESS
+ config_name=$(basename "$config_file")
+ . "$config_file"
+
+ [ -z "$DOMAINS" ] && log err "DOMAINS is not set." && continue
+ [ -z "$TOKEN" ] && log err "TOKEN is not set." && continue
+
+ query_url="https://www.duckdns.org/update?domains=$(url_encode "$DOMAINS")&token=$(url_encode "$TOKEN")"
+
+ if [ -n "$IPV6_ADDRESS" ]; then
+ ipv6="$IPV6_ADDRESS"
+ elif [ -n "$IPV6_URL" ]; then
+ if ! ipv6=$(curl -s "$IPV6_URL"); then
+ log err "Failed to get the IPV6 address using IPV6_URL. Unable to update the IPv6 address."
+ unset -v ipv6
+ fi
+ fi
+ [ -n "$ipv6" ] && query_url="${query_url}&ipv6=$(url_encode "$ipv6")"
+
+ if [ -n "$IPV4_ADDRESS" ]; then
+ ipv4="$IPV4_ADDRESS"
+ elif [ -n "$IPV4_URL" ]; then
+ if ! ipv4=$(curl -s "$IPV4_URL"); then
+ if [ -z "$ipv6" ]; then
+ log warn "Failed to get the IPv4 address using IPV4_URL. Falling back to DuckDNS' automatic address detection."
+ else
+ # DuckDNS doesn't try to automatically detect the IPv4 address if you also specify an IPv6 address.
+ log warn "Failed to get the IPv4 address using IPV4_URL. Unable to update the IPv4 address."
+ fi
+ unset -v ipv4
+ fi
+ fi
+ [ -n "$ipv4" ] && query_url="${query_url}&ip=$(url_encode "$ipv4")"
+
+ if [ "$(curl -s "$query_url")" = "OK" ]; then
+ log info "Successfully updated the DuckDNS domains."
+ else
+ log err "Failed to update the DuckDNS domains."
+ fi
+done
+unset -v config_name
+log info "Finished updating the DuckDNS domains."
+
+exit "$failed"
diff --git a/duckdns.timer b/duckdns.timer
new file mode 100644
index 000000000000..ab653da73218
--- /dev/null
+++ b/duckdns.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Update DuckDNS domain addresses every 10 minutes
+
+[Timer]
+OnCalendar=*:0/10
+
+[Install]
+WantedBy=network-online.target