diff --git a/emhttp/plugins/dynamix/NetworkExtra.page b/emhttp/plugins/dynamix/NetworkExtra.page index 3d54ee7ba7..375e89b752 100644 --- a/emhttp/plugins/dynamix/NetworkExtra.page +++ b/emhttp/plugins/dynamix/NetworkExtra.page @@ -63,6 +63,8 @@ $(function(){
+ + diff --git a/emhttp/plugins/dynamix/scripts/reload_services b/emhttp/plugins/dynamix/scripts/reload_services index babe9c7c15..4c2c2f48d3 100755 --- a/emhttp/plugins/dynamix/scripts/reload_services +++ b/emhttp/plugins/dynamix/scripts/reload_services @@ -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 diff --git a/emhttp/plugins/dynamix/scripts/update_services b/emhttp/plugins/dynamix/scripts/update_services index 652e555b2d..a27695d253 100755 --- a/emhttp/plugins/dynamix/scripts/update_services +++ b/emhttp/plugins/dynamix/scripts/update_services @@ -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 diff --git a/etc/rc.d/rc.avahidaemon b/etc/rc.d/rc.avahidaemon index 33195164fc..1c9d40df6f 100755 --- a/etc/rc.d/rc.avahidaemon +++ b/etc/rc.d/rc.avahidaemon @@ -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 +} + 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 @@ -149,7 +169,7 @@ case "$1" in avahid_reload ;; 'update') - avahid_update + avahid_update "$2" ;; 'status') avahid_status