p910nd: init: line-break and conditionalize mDNS properties
authorPaul Donald <newtwen@gmail.com>
Sun, 11 Feb 2024 02:30:56 +0000 (03:30 +0100)
committerPaul Donald <newtwen@gmail.com>
Wed, 14 Feb 2024 22:55:01 +0000 (23:55 +0100)
Signed-off-by: Paul Donald <newtwen@gmail.com>
(cherry picked from commit ffa1bbbe7844aca3ae465cc7f1ba018cc4590579)

net/p910nd/files/p910nd.init

index ad0ddfe11c9bf55d6fc791fe9fc468794c8b2255..1c305a80f8b551d2a849230cf25ece2d4e1f0b2f 100644 (file)
@@ -54,7 +54,19 @@ start_p910nd() {
                        config_get mdns_mfg "$section" mdns_mfg
                        config_get mdns_mdl "$section" mdns_mdl
                        config_get mdns_cmd "$section" mdns_cmd
-                       procd_add_mdns "pdl-datastream" "tcp" "$((port+9100))" "note=$mdns_note" "ty=$mdns_ty" "product=$mdns_product" "usb_MFG=$mdns_mfg" "usb_MDL=$mdns_mdl" "usb_CMD=$mdns_cmd"
+
+                       # Set initial arguments
+                       set -- "pdl-datastream" "tcp" "$((port+9100))"
+                       # bonjourprinting-1.2.1.pdf spec mandates (at least) MFG, MDL, CMD for Socket type
+                       [ -n "$mdns_note" ] && set -- "$@" "note=$mdns_note"
+                       [ -n "$mdns_ty" ] && set -- "$@" "ty=$mdns_ty"
+                       [ -n "$mdns_product" ] && set -- "$@" "product=$mdns_product"
+                       [ -n "$mdns_mfg" ] && set -- "$@" "usb_MFG=$mdns_mfg"
+                       [ -n "$mdns_mdl" ] && set -- "$@" "usb_MDL=$mdns_mdl"
+                       [ -n "$mdns_cmd" ] && set -- "$@" "usb_CMD=$mdns_cmd"
+
+                       # Call procd_add_mdns with the positional parameters
+                       procd_add_mdns "$@"
                fi
                procd_close_instance
        fi