From 00d14e9bb734dcf123d250cefe71526fff7805b2 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Sun, 11 Feb 2024 19:02:57 +0100 Subject: [PATCH] p910nd: hotplug: minor bug fixes Commit driver_home defaults before continuing Fix missing path for serial number acquisition Store current device if no previously configured device had one. Also set CHAR_DEV so the printer can get its driver sent on first run. Signed-off-by: Paul Donald (cherry picked from commit 5bc581e6986c84e81d4827b244bbf0deacad6e00) --- net/p910nd/files/p910nd.hotplug | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/net/p910nd/files/p910nd.hotplug b/net/p910nd/files/p910nd.hotplug index b3c98a5c4a..ed9e97d0af 100644 --- a/net/p910nd/files/p910nd.hotplug +++ b/net/p910nd/files/p910nd.hotplug @@ -120,6 +120,12 @@ case $BIP in ;; esac +# Verify that we have p910nd settings +if ! uci -q get $DAEMON; then + touch /etc/config/$DAEMON + uci -q add $DAEMON $DAEMON + uci -q commit +fi # Next, we need THIS_USB_VIDPID. This is to ensure that we send the right blob # to the right USB printer. THIS_USB_VIDPID is an anchor, or filter, if you will. @@ -138,7 +144,7 @@ THIS_USB_VIDPID="$idVendor/$idProduct" # Not always available: -iSerialNumber=$( cat "iSerialNumber" 2>/dev/null ) || iSerialNumber=$( cat "serial" 2>/dev/null ) +iSerialNumber=$( cat "$PARENT_DEVPATH/iSerialNumber" 2>/dev/null ) || iSerialNumber=$( cat "$PARENT_DEVPATH/serial" 2>/dev/null ) [ $DEBUG ] && echo iSerialNumber is $iSerialNumber @@ -151,7 +157,7 @@ ieee1284info=$(cat ""$ACTUAL_DEVPATH"/ieee1284_id" ) [ -z $(uci -q get $DAEMON.@hotplug[0]) ] && uci -q add $DAEMON hotplug # # Absent the driver_home path config, set it to a default -[ -z $(uci -q get $DAEMON.@hotplug[0].driver_home) ] && uci -q set $DAEMON.@hotplug[-1].driver_home=$DRIVER_HOME_DEFAULT +[ -z $(uci -q get $DAEMON.@hotplug[0].driver_home) ] && uci -q set $DAEMON.@hotplug[-1].driver_home=$DRIVER_HOME_DEFAULT && uci -q commit $DAEMON # Make the driver folder hierarchy if ! $(mkdir -p $DRIVER_HOME_DEFAULT); then @@ -284,6 +290,9 @@ get_and_store_printer_info() { [ -z "$(eval "$uqgddu_cmd".mdns_cmt)" ] && [ -n "$CMT" ] && eval "$uqsddu_cmd.mdns_cmt='$CMT'" [ -z "$(eval "$uqgddu_cmd".mdns_sn)" ] && [ -n "$SN" ] && eval "$uqsddu_cmd.mdns_sn='$SN'" + # No previously configured device? Configure this instance. Set CHAR_DEV so we can send driver. + [ $UCI_DEV_CFG_NUMBER -eq -1 ] && eval "$uqsddu_cmd.device=/dev/'$DEVNAME'" && CHAR_DEV=/dev/"$DEVNAME" + if [ -n "$MFG" ] && [ -n "$MDL" ] && [ -n "$DRIVER_BLOBNAME_TAIL" ] && [ -z "$($uqgddu_cmd.driver_file)" ]; then DRIVER_FILE="$MFG"_"$MDL"_"$DRIVER_BLOBNAME_TAIL" # Make blob filename more friendly: change space to underscore -- 2.30.2