Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions emhttp/plugins/dynamix/NetworkExtra.page
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ $(function(){
<form markdown="1" name="network_extra" method="POST" action="/update.php" target="progressFrame" onsubmit="return prepareText(this)">
<input type="hidden" name="#file" value="<?=$cfg?>">
<input type="hidden" name="#command" value="/webGui/scripts/update_services">
<input type="hidden" name="#arg[1]" value="1">
<input type="hidden" name="#arg[2]" value="force">
<input type="hidden" name="include_interfaces" value="">
<input type="hidden" name="exclude_interfaces" value="">

Expand Down
6 changes: 5 additions & 1 deletion emhttp/plugins/dynamix/scripts/reload_services
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ else
fi

for cmd in $SERVICES; do
/etc/rc.d/rc.$cmd update &>/dev/null
if [[ $cmd == avahidaemon && $1 == force ]]; then
/etc/rc.d/rc.$cmd update force &>/dev/null
else
/etc/rc.d/rc.$cmd update &>/dev/null
fi
done
exit 0
6 changes: 5 additions & 1 deletion emhttp/plugins/dynamix/scripts/update_services
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ if [[ -n $1 && ! $1 =~ ^[0-9]+$ ]]; then
else
DELAY=${1:-1}
fi
case "${2:-}" in
'force') MODE=force ;;
*) MODE= ;;
esac

echo "sleep $DELAY; /usr/local/emhttp/webGui/scripts/reload_services" | at -M now 2>/dev/null
echo "sleep $DELAY; /usr/local/emhttp/webGui/scripts/reload_services $MODE" | at -M now 2>/dev/null
log "queue new job $(queue), wait for ${DELAY}s"
exit 0
24 changes: 22 additions & 2 deletions etc/rc.d/rc.avahidaemon
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,28 @@ avahid_reload(){
fi
}

bind_changed(){
local CURRENT=",$1," NEXT=",$2," IFACE
# A new active bind target needs a restart so avahi-daemon reads it.
for IFACE in ${2//,/ }; do
[[ $CURRENT == *",$IFACE,"* ]] || return 0
done
# Missing inactive targets are usually transient carrier/DHCP loss; keep
# Avahi running so it can notice the interface when it returns.
for IFACE in ${1//,/ }; do
[[ $NEXT == *",$IFACE,"* || -z $(show dev "$IFACE") ]] || return 0
done
# Shell convention: 1 means "no meaningful bind change" for this predicate.
return 1
}
Comment on lines +122 to +135

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify the 'show' command exists and check its usage with 'dev'

# Check if 'show' is a function or executable
type show 2>/dev/null || echo "show command not found in PATH"

# Search for 'show' function definition in rc scripts
rg -n "^show\s*\(\)" --type=sh --glob='etc/rc.d/*'

# Search for 'show dev' usage patterns
rg -n -C3 "show dev" --type=sh --glob='etc/rc.d/*'

Repository: unraid/webgui

Length of output: 3385


show dev is provided by rc.library.source; align semantics with inactivity checks
etc/rc.d/rc.library.source defines show() (around line 57) and relies on show dev output in -n/-z conditionals (e.g., around line 97 and line 120), so the earlier “command not defined” concern is just an artifact of not sourcing the library in isolation. The key remaining alignment is that show dev <iface> returning empty (which bind_changed tests via -z $(show dev "$IFACE")) truly means the interface is inactive/transiently down—not merely that it currently has no addresses.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@etc/rc.d/rc.avahidaemon` around lines 122 - 131, bind_changed currently
treats an empty show dev output as "inactive" by using -z $(show dev "$IFACE");
update bind_changed to explicitly interpret the semantics of show dev (as
defined in rc.library.source) instead of relying on emptiness — locate the
second for-loop in bind_changed and replace the -z $(show dev "$IFACE") test
with a check that parses show dev "$IFACE" output for the interface state (e.g.,
test for "up"/"active" or absence of "up") so the condition truly reflects an
inactive/transiently-down interface according to show()'s output format.


avahid_update(){
if avahid_running && check && [[ "$(this allow-interfaces)" != "$BIND" ]]; then
local CURRENT
if avahid_running && check; then
CURRENT="$(this allow-interfaces)"
[[ "$CURRENT" != "$BIND" ]] || return 0
# Network hooks are often transient; explicit config applies pass "force".
[[ $1 == force ]] || bind_changed "$CURRENT" "$BIND" || return 0
log "Updating $DAEMON..."
avahid_restart # note we need restart here, not reload in order to update interfaces
fi
Expand Down Expand Up @@ -149,7 +169,7 @@ case "$1" in
avahid_reload
;;
'update')
avahid_update
avahid_update "$2"
;;
'status')
avahid_status
Expand Down
Loading