ddns-scripts: switch to procd handling
authorFlorian Eckert <redacted>
Fri, 13 Mar 2026 10:18:46 +0000 (11:18 +0100)
committerFlorian Eckert <redacted>
Fri, 20 Mar 2026 06:30:39 +0000 (07:30 +0100)
The 'ddns-scripts' packages still uses not the procd service handling.
This commit changes this.

This change also resolves the issue where, if a UCI configuration is
already present, the process is blocked during installation via APK and
does not complete.

Signed-off-by: Florian Eckert <redacted>
Tested-by: Luiz Angelo Daros de Luca <redacted>
net/ddns-scripts/Makefile
net/ddns-scripts/files/etc/hotplug.d/iface/ddns
net/ddns-scripts/files/etc/init.d/ddns
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_lucihelper.sh
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh

index 1ac0210b2e3a3328060c50d46c43b3226de8c12e..5b5277e68b55d9967b226fc34d8c6f03ab290d68 100644 (file)
@@ -7,8 +7,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ddns-scripts
-PKG_VERSION:=2.8.2
-PKG_RELEASE:=93
+PKG_VERSION:=2.8.3
+PKG_RELEASE:=1
 
 PKG_LICENSE:=GPL-2.0
 
index 9ef172deb663df64a4d1063cd19898250afb29eb..dd58f9180cf01fe2bb0874137193c72e22aa962b 100644 (file)
@@ -1,11 +1,42 @@
 #!/bin/sh
 
-# there are other ACTIONs like ifupdate we don't need
+. /lib/functions.sh
+
+start_ddns_service() {
+       local cfg="$1"
+       local interface_event="$2"
+       local action="$3"
+
+       local interface
+
+       config_get interface $cfg interface
+       [ -z "$interface" ] && return
+
+       [ "$interface" != "$interface_event" ] && return
+
+       case "$action" in
+       ifup)
+               /etc/init.d/ddns start "$cfg"
+               ;;
+       ifdown)
+               /etc/init.d/ddns stop "$cfg"
+               ;;
+       esac
+}
+
+ddns_service() {
+       local action="$1"
+       local interface="$2"
+
+       config_load ddns
+       config_foreach start_ddns_service "service" "$interface" "$action"
+}
+
 case "$ACTION" in
-       ifup)                                   # OpenWrt is giving a network not phys. Interface
-               /etc/init.d/ddns enabled && /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- start
+       ifup)
+               /etc/init.d/ddns enabled && ddns_service "ifup" "$INTERFACE"
                ;;
        ifdown)
-               /usr/lib/ddns/dynamic_dns_updater.sh -n "$INTERFACE" -- stop
+               ddns_service "ifdown" "$INTERFACE"
                ;;
 esac
index 7c82165201337ab374abd17cc02c359d1cadc622..f138590b69e817de69defdfe75428e35ab0c42e9 100644 (file)
@@ -1,31 +1,51 @@
 #!/bin/sh /etc/rc.common
+
+USE_PROCD=1
 START=95
 STOP=10
 
-boot() {
-       return 0
-}
+PROG=/usr/lib/ddns/dynamic_dns_updater.sh
 
-kill() {
-       /usr/lib/ddns/dynamic_dns_updater.sh -- kill
-       return 0
-}
+start_ddns() {
+       local cfg="$1"
+
+       local enabled
 
-reload() {
-       restart
+       config_get_bool enabled $cfg enabled '0'
+       [ "$enabled" = "0" ] && return
+
+       procd_open_instance "$cfg"
+       procd_set_param command $PROG
+       procd_append_param command -S "$cfg"
+       procd_set_param respawn
+       procd_close_instance
 }
 
-restart() {
-       /usr/lib/ddns/dynamic_dns_updater.sh -- stop
-       sleep 1 # give time to shutdown
-       /usr/lib/ddns/dynamic_dns_updater.sh -- start
+start_ddns_service() {
+       local cfg="$1"
+       local section="$2"
+
+       # start section if no section name is specified
+       [ -z "$section" ] && {
+               start_ddns "$cfg"
+               return
+       }
+
+       # start 'exactly' this section if a section name is specified
+       [ "$section" = "$cfg" ] && {
+               start_ddns "$cfg"
+               return
+       }
 }
 
-start() {
-       /usr/lib/ddns/dynamic_dns_updater.sh -- start
+start_service() {
+       local section="$1"
+
+       config_load ddns
+       config_foreach start_ddns_service "service" "$section"
 }
 
-stop() {
-       /usr/lib/ddns/dynamic_dns_updater.sh -- stop
-       return 0
+service_triggers()
+{
+       procd_add_reload_trigger ddns
 }
index c07a859740e984f5513febfe0cffefaf4be56f36..94d3a5b8c6392083f717d8fa7be8c8a0910db46d 100644 (file)
@@ -165,69 +165,6 @@ load_all_config_options()
        return 0
 }
 
-# read's all service sections from ddns config
-# $1 = Name of variable to store
-load_all_service_sections() {
-       local __DATA=""
-       config_cb()
-       {
-               # only look for section type "service", ignore everything else
-               [ "$1" = "service" ] && __DATA="$__DATA $2"
-       }
-       config_load "ddns"
-
-       eval "$1=\"$__DATA\""
-       return
-}
-
-# starts updater script for all given sections or only for the one given
-# $1 = interface (Optional: when given only scripts are started
-# configured for that interface)
-# used by /etc/hotplug.d/iface/95-ddns on IFUP
-# and by /etc/init.d/ddns start
-start_daemon_for_all_ddns_sections()
-{
-       local event_if sections section_id configured_if
-       event_if="$1"
-
-       load_all_service_sections sections
-       for section_id in $sections; do
-               config_get configured_if "$section_id" interface "wan"
-               [ -z "$event_if" ] || [ "$configured_if" = "$event_if" ] || continue
-               /usr/lib/ddns/dynamic_dns_updater.sh -v "$VERBOSE" -S "$section_id" -- start &
-       done
-}
-
-# stop sections process incl. childs (sleeps)
-# $1 = section
-stop_section_processes() {
-       local pid_file
-       pid_file="$ddns_rundir/$1.pid"
-       [ $# -ne 1 ] && write_log 12 "Error: 'stop_section_processes()' requires exactly one parameter"
-
-       [ -e "$pid_file" ] && {
-               xargs kill < "$pid_file" 2>/dev/null && return 1
-       }
-       return 0 # nothing killed
-}
-
-# stop updater script for all defines sections or only for one given
-# $1 = interface (optional)
-# used by /etc/hotplug.d/iface/95-ddns on 'ifdown'
-# and by /etc/init.d/ddns stop
-# needed because we also need to kill "sleep" child processes
-stop_daemon_for_all_ddns_sections() {
-       local event_if sections section_id configured_if
-       event_if="$1"
-
-       load_all_service_sections sections
-       for section_id in $sections;    do
-               config_get configured_if "$section_id" interface "wan"
-               [ -z "$event_if" ] || [ "$configured_if" = "$event_if" ] || continue
-               stop_section_processes "$section_id"
-       done
-}
-
 # reports to console, logfile, syslog
 # $1   loglevel 7 == Debug to 0 == EMERG
 #      value +10 will exit the scripts
index 1268503dd464e32ea3d1fc18883f8b02dea9ac6a..f6b68f3026edecca7466ee0dabbb78c0a80dfdd9 100644 (file)
@@ -44,7 +44,6 @@ Parameters:
 
  -h                  => show this help and exit
  -L                  => use_logfile=1    (default 0)
- -v LEVEL            => VERBOSE=LEVEL    (default 0)
  -V                  => show version and exit
 
 EOF
@@ -61,8 +60,6 @@ SECTION_ID="lucihelper"
 LOGFILE="$ddns_logdir/$SECTION_ID.log"
 DATFILE="$ddns_rundir/$SECTION_ID.$$.dat"      # save stdout data of WGet and other extern programs called
 ERRFILE="$ddns_rundir/$SECTION_ID.$$.err"      # save stderr output of WGet and other extern programs called
-DDNSPRG="/usr/lib/ddns/dynamic_dns_updater.sh"
-VERBOSE=0              # no console logging
 # global variables normally set by reading DDNS UCI configuration
 use_syslog=0           # no syslog
 use_logfile=0          # no logfile
@@ -88,7 +85,6 @@ while getopts ":6d:fghi:l:n:p:s:S:tu:Lv:V" OPT; do
                u)      ip_url="$OPTARG"; ip_source="web";;
                h)      usage; exit 255;;
                L)      use_logfile=1;;
-               v)      VERBOSE=$OPTARG;;
                S)      SECTION=$OPTARG;;
                V)      printf %s\\n "ddns-scripts $VERSION"; exit 255;;
                :)      usage_err "option -$OPTARG missing argument";;
@@ -148,27 +144,19 @@ case "$1" in
                ;;
        start)
                [ -z "$SECTION" ] &&  usage_err "command 'start': 'SECTION' not set"
-               if [ "$VERBOSE" -eq 0 ]; then   # start in background
-                       ("$DDNSPRG" -v 0 -S "$SECTION" -- start >/dev/null 2>&1 &)
-               else
-                       "$DDNSPRG" -v "$VERBOSE" -S "$SECTION" -- start
-               fi
+               /etc/init.d/ddns start "$SECTION"
                ;;
        reload)
-               "$DDNSPRG" -- reload
+               /etc/init.d/ddns reload
                ;;
        restart)
-               "$DDNSPRG" -- stop
-               sleep 1
-               "$DDNSPRG" -- start >/dev/null 2>&1
+               /etc/init.d/ddns restart
                ;;
        stop)
                if [ -n "$SECTION" ]; then
-                       # section stop
-                       "$DDNSPRG" -S "$SECTION" -- stop
+                       /etc/init.d/ddns stop "$SECTION"
                else
-                       # global stop
-                       "$DDNSPRG" -- stop
+                       /etc/init.d/ddns stop
                fi
                ;;
        *)
index 3815e3f07e31d4669ba74e1177d4d6121896d1c0..d809fd5e3457569829c81982e457fe5f1a71d527 100644 (file)
@@ -19,14 +19,9 @@ usage() {
        cat << EOF
 
 Usage:
- $MYPROG [options] -- command
-
-Commands:
-start                Start SECTION or NETWORK or all
-stop                 Stop SECTION or NETWORK or all
+ $MYPROG [options]
 
 Parameters:
- -n NETWORK          Start/Stop sections in background monitoring NETWORK, force VERBOSE=0
  -S SECTION          SECTION to start
                      use either -N NETWORK or -S SECTION
 
@@ -53,7 +48,6 @@ while getopts ":hv:dn:S:V" OPT; do
                h)      usage; exit 0;;
                v)      VERBOSE=$OPTARG;;
                d)      DRY_RUN=1;;
-               n)      NETWORK=$OPTARG;;
                S)      SECTION_ID=$OPTARG;;
                V)      printf %s\\n "ddns-scripts $VERSION"; exit 0;;
                :)      usage_err "option -$OPTARG missing argument";;
@@ -63,41 +57,7 @@ while getopts ":hv:dn:S:V" OPT; do
 done
 shift $((OPTIND - 1 )) # OPTIND is 1 based
 
-[ -n "$NETWORK" -a -n "$SECTION_ID" ] && usage_err "use either option '-N' or '-S' not both"
-[ $# -eq 0 ] && usage_err "missing command"
-[ $# -gt 1 ] && usage_err "to much commands"
-
-case "$1" in
-       start)
-               if [ -n "$NETWORK" ]; then
-                       start_daemon_for_all_ddns_sections "$NETWORK"
-                       exit 0
-               fi
-               if [ -z "$SECTION_ID" ]; then
-                       start_daemon_for_all_ddns_sections
-                       exit 0
-               fi
-               ;;
-       stop)
-               if [ -n "$SECTION_ID" ]; then
-                       stop_section_processes "$SECTION_ID"
-                       exit 0
-               fi
-               if [ -n "$NETWORK" ]; then
-                       stop_daemon_for_all_ddns_sections "$NETWORK"
-                       exit 0
-               else
-                       stop_daemon_for_all_ddns_sections
-                       exit 0
-               fi
-               exit 1
-               ;;
-       kill)
-               killall dynamic_dns_updater.sh 2>/dev/null
-               exit $?
-               ;;
-       *)      usage_err "unknown command - $1";;
-esac
+[ -z "$SECTION_ID" ] && usage_err "option '-N' is missing"
 
 # set file names
 PIDFILE="$ddns_rundir/$SECTION_ID.pid" # Process ID file
git clone https://git.99rst.org/PROJECT