Initialize Git Repository: 'DDNS-Client'
DDNS-Client / DDNS-Client (amd64, cicd.any, bookworm trixie noble, main) (push) Successful in 10s
DDNS-Client / DDNS-Client (arm64, cicd.any, bookworm trixie noble, main) (push) Successful in 11s

This commit is contained in:
Cantibra
2026-05-04 21:21:44 +02:00
commit 603356d07d
16 changed files with 801 additions and 0 deletions
@@ -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
@@ -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 '{split($2,a,"/"); print a[1]}' | /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 '{split($2,a,"/"); print a[1]}')
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 '{split($2,a,"/"); print a[1]}' | /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 '{split($2,a,"/"); print a[1]}')
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 '{split($2,a,"/"); print a[1]}' | /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 '{split($2,a,"/"); print a[1]}' | /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 '{split($2,a,"/"); print a[1]}' | /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 '{split($2,a,"/"); print a[1]}' | /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