Initialize Git Repository: 'DDNS-Client'
All checks were successful
DDNS-Client (Bookworm) / DDNS-Client [arm64] (push) Successful in 10s
DDNS-Client (Bookworm) / DDNS-Client [amd64] (push) Successful in 11s
DDNS-Client (Noble) / DDNS-Client [arm64] (push) Successful in 11s
DDNS-Client (Noble) / DDNS-Client [amd64] (push) Successful in 11s
DDNS-Client (Trixie) / DDNS-Client [arm64] (push) Successful in 10s
DDNS-Client (Trixie) / DDNS-Client [amd64] (push) Successful in 10s

This commit is contained in:
Cantibra
2026-01-26 06:10:00 +01:00
commit a99a3aed35
19 changed files with 1478 additions and 0 deletions

11
root/DEBIAN/control Normal file
View File

@@ -0,0 +1,11 @@
Package: ddns-client
Version: 1.0.0
Architecture:
Installed-Size:
Depends: wget, net-tools
Recommends: iproute2
Priority: optional
Section: misc
Homepage: http://www.privlab.it
Maintainer: PrivLab <repository@privlab.it>
Description: Dynamic Domain Name System Client Update Service

38
root/DEBIAN/postinst Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/sh
set -e
set -u
if [ -d '/run/systemd/system' ]; then
/usr/bin/systemctl --system daemon-reload > '/dev/null' 2>&1 || \
/usr/bin/true
fi
case "${1}" in
configure)
if [ -x '/usr/bin/deb-systemd-helper' ]; then
/usr/bin/deb-systemd-helper unmask 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-helper unmask 'ddns-client.service' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
if /usr/bin/deb-systemd-helper --quiet was-enabled 'ddns-client.timer'; then
/usr/bin/deb-systemd-helper enable 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
else
/usr/bin/deb-systemd-helper update-state 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
if [ -x '/usr/bin/deb-systemd-invoke' ]; then
/usr/bin/systemctl --system daemon-reload > '/dev/null' 2>&1 || \
/usr/bin/true
if [ -n "${2}" ]; then
_dh_action='restart'
else
_dh_action='start'
fi
/usr/bin/deb-systemd-invoke "${_dh_action}" 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
;;
esac

33
root/DEBIAN/postrm Normal file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/sh
set -e
set -u
if [ -d '/run/systemd/system' ]; then
/usr/bin/systemctl --system daemon-reload > '/dev/null' 2>&1 || \
/usr/bin/true
fi
case "${1}" in
remove)
if [ -x '/usr/bin/deb-systemd-helper' ]; then
/usr/bin/deb-systemd-helper mask 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-helper mask 'ddns-client.service' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
;;
purge)
if [ -x '/usr/bin/deb-systemd-helper' ]; then
/usr/bin/deb-systemd-helper purge 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-helper purge 'ddns-client.service' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-helper unmask 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-helper unmask 'ddns-client.service' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
/usr/bin/rm --force --recursive '/var/trash'
;;
esac

17
root/DEBIAN/prerm Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/sh
set -e
set -u
case "${1}" in
remove)
if [ -x '/usr/bin/deb-systemd-invoke' ]; then
/usr/bin/deb-systemd-invoke stop 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-invoke stop 'ddns-client.service' > '/dev/null' 2>&1 || \
/usr/bin/true
/usr/bin/deb-systemd-invoke disable 'ddns-client.timer' > '/dev/null' 2>&1 || \
/usr/bin/true
fi
;;
esac

View File

@@ -0,0 +1,17 @@
# /etc/cron.d/ddns-client
SHELL=/usr/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# * * * * * user command to execute
# | | | | |
# | | | | |
# | | | | |_______________ day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# | | | |______________________ month (1 - 12)
# | | |_____________________________ day of month (1 - 31)
# | |____________________________________ hour (0 - 23)
# |___________________________________________ min (0 - 59)
#
*/5 * * * * root if [ -d '/run/systemd/system' ]; then exit 0; fi; if '/usr/lib/ddns-client/check_condition'; then '/usr/lib/ddns-client/start_update'; fi;
#

78
root/etc/ddns-client.conf Normal file
View File

@@ -0,0 +1,78 @@
#####################################
# Dynamic Domain Name System Client #
#####################################
# --- Service Settings --- #
## TIMER
## Sets the state for whether a DNS update is
## performed every 5 minutes.
##
TIMER='false'
# --- Provider Settings --- #
## PROVIDER
## Sets the provider to be contacted during a DNS
## update using the update URL.
##
## Value Description
## ----------------------------------------------------
## webstuebchen webstuebchen's DDNS Service
##
PROVIDER=''
## USERNAME
## Username to authenticate with the provider.
##
USERNAME=''
## PASSWORD
## Password to authenticate with the provider.
##
PASSWORD=''
## HOSTNAME
## Fully Qualified Domain Name which will be updated.
## eg 'domain.com www.domain.com'
##
HOSTNAME=''
# --- Network Settings --- #
## IP
## Defines the version of the IP addresses to be used
## for a DNS update.
##
## Value Description
## ----------------------------------------------------
## IP4 IPv4 Address
## IP6 IPv6 Address
## IP64 IPv4/IPv6 Address (Dual-Stack)
##
IP='IP64'
## NETWORK
##
##
## Value Description
## ----------------------------------------------------
## public Public IP Address is used
## private Private IP Address is used
##
NETWORK='public'
## INTERFACE
##
##
## Value Description
## ----------------------------------------------------
## lo localhost Interface is used
## *interface* Given Interface is used
INTERFACE='lo'

View File

@@ -0,0 +1,10 @@
[Unit]
Description=Dynamic Domain Name System Client
After=network.target network-online.target
Wants=network.target
[Service]
Type=oneshot
ExecCondition=/usr/lib/ddns-client/check_conditions
ExecStart=/usr/lib/ddns-client/start_update
ProtectSystem=strict

View File

@@ -0,0 +1,9 @@
[Unit]
Description=Dynamic Domain Name System Client
[Timer]
OnCalendar=*-*-* *:00/5:00
Persistent=true
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1,84 @@
#!/usr/bin/bash
###
#
# Options Section
#
###
set -e
set -u
set -o pipefail
###
#
# Variable Section
#
###
source '/etc/ddns-client.conf'
###
#
# Runtime Environment
#
###
if [[ "${TIMER}" != 'true' ]]; then
exit 1
fi
if [[ -z "${HOSTNAME}" ]]; then
/usr/bin/echo "ERROR: The configuration option 'HOSTNAME' has not been set."
exit 1
fi
if ! /usr/bin/ping -c '1' 'ident.me' &> '/dev/null'; then
/usr/bin/echo "ERROR: The Identity Provider 'ident.me' is not reachable."
exit 1
fi
case "${PROVIDER}" in
webstuebchen)
if ! /usr/bin/ping -c '1' 'dns.webstuebchen.com' &> '/dev/null'; then
/usr/bin/echo "ERROR: The DNS Provider 'webstuenchen' is not reachable."
exit 1
fi
if [[ -z "${USERNAME}" ]]; then
/usr/bin/echo "ERROR: The configuration option 'USERNAME' has not been set."
exit 1
fi
if [[ -z "${PASSWORD}" ]]; then
/usr/bin/echo "ERROR: The configuration option 'PASSWORD' has not been set."
exit 1
fi
;;
*)
/usr/bin/echo "Error: The configuration option 'PROVIDER' has a wrong value."
exit 1
;;
esac
case "${IP}" in
IP4|IP6|IP64)
true
;;
*)
/usr/bin/echo "ERROR: The configuration option 'IP' has a wrong value."
exit 1
;;
esac
case "${NETWORK}" in
private)
if [[ -z "${INTERFACE}" ]]; then
/usr/bin/echo 'ERROR: The configuration option 'INTERFACE' has not been set.'
exit 1
fi
;;
public)
true
;;
*)
/usr/bin/echo "ERROR: The configuration option 'NETWORK' has a wrong value."
exit 1
;;
esac

View File

@@ -0,0 +1,161 @@
#!/usr/bin/bash
###
#
# Options Section
#
###
set -e
set -o pipefail
###
#
# Variable Section
#
###
source '/etc/ddns-client.conf'
###
#
# Function Section
#
###
function ip_check () {
case "${IP}" in
IP4)
if [[ -z "${IP4_ADDRESS}" ]]; then
/usr/bin/echo 'ERROR: The Identity Provider did not respond with an valid IP address.'
exit 1
fi
;;
IP6)
if [[ -z "${IP6_ADDRESS}" ]]; then
/usr/bin/echo 'ERROR: The Identity Provider did not respond with an valid IP address.'
exit 1
fi
;;
IP64)
if [[ -z "${IP4_ADDRESS}" ]] || \
[[ -z "${IP6_ADDRESS}" ]]; then
/usr/bin/echo 'ERROR: The Identity Provider did not respond with an valid IP address.'
exit 1
fi
;;
esac
}
###
#
# Runtime Environment
#
###
if [[ -n "${INVOCATION_ID}" ]]; then
if ! source '/usr/lib/ddns-client/check_conditions'; then
exit 1
fi
fi
case "${NETWORK}" in
private)
if [[ ! -L "/sys/class/net/${INTERFACE}" ]]; then
/usr/bin/echo 'ERROR: The options 'INTERFACE' in the configuration file is not existing.'
exit 1
fi
case "${IP}" in
IP4)
if type ip >/dev/null 2>&1; then
IP4_ADDRESS=$(/usr/bin/ip -4 addr show "${INTERFACE}" | /usr/bin/grep ---only-matching --perl-regexp '(?<=inet\s)\d+(\.\d+){3}')
elif type ifconfig >/dev/null 2>&1; then
IP4_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep 'inet ' | /usr/bin/mawk '{print $2}')
fi
;;
IP6)
if type ip >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/bin/ip -6 addr show "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --extended-regexp '^fd[0-9a-fA-F]{2}::')
elif type ifconfig >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep --extended-regexp 'inet6 (fd[0-9a-fA-F]{2}::|::1)' | /usr/bin/mawk '{print $2}')
fi
;;
IP64)
if type ip >/dev/null 2>&1; then
IP4_ADDRESS=$(/usr/bin/ip -4 addr show "${INTERFACE}" | /usr/bin/grep ---only-matching --perl-regexp '(?<=inet\s)\d+(\.\d+){3}')
IP6_ADDRESS=$(/usr/bin/ip -6 addr show "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --extended-regexp '^fd[0-9a-fA-F]{2}::')
elif type ifconfig >/dev/null 2>&1; then
IP4_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep 'inet ' | /usr/bin/mawk '{print $2}')
IP6_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep --extended-regexp 'inet6 (fd[0-9a-fA-F]{2}::|::1)' | /usr/bin/mawk '{print $2}')
fi
esac
ip_check
;;
public)
case "${IP}" in
IP4)
IP4_ADDRESS=$(/usr/bin/wget --quiet --output-document='-' --timeout='3' --inet4-only --https-only --no-hsts 'ident.me')
;;
IP6)
if type ip >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/bin/ip -6 addr show "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --invert-match --extended-regexp '^(fd[0-9a-fA-F]{2}::|fe[0-9a-fA-F]{2}::)')
elif type ifconfig >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --invert-match --extended-regexp '^(fd[0-9a-fA-F]{2}::|fe[0-9a-fA-F]{2}::)')
fi
;;
IP64)
IP4_ADDRESS=$(/usr/bin/wget --quiet --output-document='-' --timeout='3' --inet4-only --https-only --no-hsts 'ident.me')
if type ip >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/bin/ip -6 addr show "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --invert-match --extended-regexp '^(fd[0-9a-fA-F]{2}::|fe[0-9a-fA-F]{2}::)')
elif type ifconfig >/dev/null 2>&1; then
IP6_ADDRESS=$(/usr/sbin/ifconfig "${INTERFACE}" | /usr/bin/grep 'inet6' | /usr/bin/mawk '{print $2}' | /usr/bin/grep --invert-match --extended-regexp '^(fd[0-9a-fA-F]{2}::|fe[0-9a-fA-F]{2}::)')
fi
;;
esac
ip_check
;;
esac
for HOST in ${HOSTNAME}; do
case "${PROVIDER}" in
webstuebchen)
URLIP4="https://dns.webstuebchen.com/${USERNAME}/update.php?user=${USERNAME}&password=${PASSWORD}&ipv4=${IP4_ADDRESS}&domain=${HOST}"
URLIP6="https://dns.webstuebchen.com/${USERNAME}/update.php?user=${USERNAME}&password=${PASSWORD}&ipv6=${IP6_ADDRESS}&domain=${HOST}"
URLIP64="https://dns.webstuebchen.com/${USERNAME}/update.php?user=${USERNAME}&password=${PASSWORD}&ipv4=${IP4_ADDRESS}&ipv6=${IP6_ADDRESS}&domain=${HOST}"
;;
esac
case "${IP}" in
IP4)
if /usr/bin/wget --quiet --output-document='-' --no-hsts "${URLIP4}"; then
/usr/bin/echo "The DNS [A] Record named '${HOST}' was updated to '${IP4_ADDRESS}'."
else
/usr/bin/echo "ERROR: The DNS [A] Record named '${HOST}' can not be updated."
exit 1
fi
;;
IP6)
if /usr/bin/wget --quiet --output-document='-' --no-hsts "${URLIP6}"; then
/usr/bin/echo "The DNS [AAAA] Record named '${HOST}' was updated to '${IP6_ADDRESS}'."
else
/usr/bin/echo "ERROR: The DNS [AAAA] Record named '${HOST}' can not be updated."
exit 1
fi
;;
IP64)
if /usr/bin/wget --quiet --output-document='-' --no-hsts "${URLIP4}"; then
/usr/bin/echo "The DNS [A] Record named '${HOST}' was updated to '${IP4_ADDRESS}'."
else
/usr/bin/echo "ERROR: The DNS [A] Record named '${HOST}' can not be updated."
exit 1
fi
if /usr/bin/wget --quiet --output-document='-' --no-hsts "${URLIP6}"; then
/usr/bin/echo "The DNS [AAAA] Record named '${HOST}' was updated to '${IP6_ADDRESS}'."
else
/usr/bin/echo "ERROR: The DNS [AAAA] Record named '${HOST}' can not be updated."
exit 1
fi
;;
esac
done