Lantis wrote:I can't really tell if usblp has attached itself to your printer properly or not. It looks like it has, but the output has changed since the init script was first written.
It needs a makeover quite frankly.
If you bypass lines 60-72 in /usr/lib/gargoyle/configure_printer.sh and add a line
before line 78, it might fire up and work.
Thanks for your help till now , I am not an Expert , but searched and used WinSCP to edit this file
Before :
Code: Select all
#!/bin/sh
update_dnsmasq_conf()
{
dnsfile="$1"
new_lines="$2"
start_line=$(grep -n "BEGIN BONJOUR PRINTER CONFIGURATION" $dnsfile | sed 's/:.*$//g')
end_line=$(grep -n "END BONJOUR PRINTER CONFIGURATION" $dnsfile | sed 's/:.*$//g')
lines=$(wc -l $dnsfile | awk '{print $1 }')
rm -rf /tmp/dns.new.tmp
if [ -n "$start_line" ] ; then
if [ $start_line -gt 1 ] ; then
head -n $(($start_line-1)) $dnsfile >>/tmp/dns.new.tmp
fi
if [ $end_line -lt $lines ] ; then
tail -n $(( $lines - $end_line )) $dnsfile >>/tmp/dns.new.tmp
fi
else
cat "$dnsfile" >>/tmp/dns.new.tmp
fi
echo '###### BEGIN BONJOUR PRINTER CONFIGURATION #####' >>/tmp/dns.new.tmp
printf "$new_lines\n" >>/tmp/dns.new.tmp
echo '###### END BONJOUR PRINTER CONFIGURATION #######' >>/tmp/dns.new.tmp
original_md5=$(md5sum "$dnsfile")
original_md5=${original_md5% *}
new_md5=$(md5sum "/tmp/dns.new.tmp")
new_md5=${new_md5% *}
if [ "$original_md5" != "$new_md5" ] ; then
mv /tmp/dns.new.tmp "$dnsfile"
/etc/init.d/dnsmasq restart
else
rm -rf /tmp/dns.new.tmp
fi
}
if [ -e /tmp/printer_hotplug_lock ] ; then exit ; fi
touch /tmp/printer_hotplug_lock
count=5
while [ ! -e /sys/kernel/debug/usb/devices ] && [ $count -gt 0 ] ; do
sleep 1
count=$(( $count - 1 ))
done
if [ ! -e /sys/kernel/debug/usb/devices ] ; then
rm -rf /tmp/printer_hotplug_lock
exit
fi
usb_device_lines=$( echo $(cat "/sys/kernel/debug/usb/devices" | sed 's/^$/@@@@@/g') | sed 's/@@@@@/\n/g')
printer=$(printf "%s" "$usb_device_lines" | grep "Driver=usblp" | sed 's/^.*Product=//g' | sed 's/ .:.*$//g'| head -n1)
if [ -z "$printer" ] ; then
printer=$(printf "%s" "$usb_device_lines" | grep "Driver=usblp" | sed 's/^.*SerialNumber=//g' | sed 's/ .:.*$//g'| head -n1)
if [ -n "$printer" ] ; then
printer="Unknown Printer with S/N $printer"
else
printer=$(printf "%s" "$usb_device_lines" | grep "Driver=usblp" | sed 's/^.*Vendor=/Vendor=/g' | sed 's/ .:.*$//g'| head -n1)
if [ -n "$printer" ] ; then
printer="Unknown Printer $printer"
fi
fi
fi
p910nd_enabled=$(uci get p910nd.@p910nd[0].enabled 2>/dev/null)
p910nd_printer_name=$(uci get p910nd.@p910nd[0].printer_name 2>/dev/null)
if [ -n "$printer" ] ; then
if [ "$p910nd_enabled" != "1" ] || [ "$p910nd_printer_name" != "$printer" ] ; then
uci set p910nd.@p910nd[0].enabled="1"
uci set p910nd.@p910nd[0].printer_name="$printer"
uci commit
/etc/init.d/p910nd enable
/etc/init.d/p910nd stop >/dev/null 2>&1
/etc/init.d/p910nd start
fi
domain=$(uci get dhcp.@dnsmasq[0].domain)
hostname=$(uci get system.@system[0].hostname)
revip=$(uci get network.lan.ipaddr | sed 's/\./ /g' | awk ' { print "0."$3"."$2"."$1 ; }')
dnsmasqConfLines=""
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=b._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=db._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=r._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=dr._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=lb._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=_services._dns-sd._udp.$domain,_pdl-datastream._tcp.$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=_pdl-datastream._tcp.$domain,$hostname._pdl-datastream._tcp.$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nsrv-host=Gargoyle._pdl-datastream._tcp.$domain,$hostname.$domain,9100\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\ntxt-record=$hostname._pdl-datastream._tcp.$domain,ty=$printer,product=($printer),usb_MDL=$printer,txtvers=1,qtotal=1,priority=20\n")
update_dnsmasq_conf "/etc/dnsmasq.conf" "$dnsmasqConfLines"
#after we've found a printer we're done -- for now, only one printer at a time
elif [ "$p910nd_enabled" != "0" ] ; then
uci set p910nd.@p910nd[0].enabled=0
uci set p910nd.@p910nd[0].printer_name=""
uci commit
/etc/init.d/p910nd stop >/dev/null 2>&1
fi
rm -rf /tmp/printer_hotplug_lock
After :
Code: Select all
#!/bin/sh
update_dnsmasq_conf()
{
dnsfile="$1"
new_lines="$2"
start_line=$(grep -n "BEGIN BONJOUR PRINTER CONFIGURATION" $dnsfile | sed 's/:.*$//g')
end_line=$(grep -n "END BONJOUR PRINTER CONFIGURATION" $dnsfile | sed 's/:.*$//g')
lines=$(wc -l $dnsfile | awk '{print $1 }')
rm -rf /tmp/dns.new.tmp
if [ -n "$start_line" ] ; then
if [ $start_line -gt 1 ] ; then
head -n $(($start_line-1)) $dnsfile >>/tmp/dns.new.tmp
fi
if [ $end_line -lt $lines ] ; then
tail -n $(( $lines - $end_line )) $dnsfile >>/tmp/dns.new.tmp
fi
else
cat "$dnsfile" >>/tmp/dns.new.tmp
fi
echo '###### BEGIN BONJOUR PRINTER CONFIGURATION #####' >>/tmp/dns.new.tmp
printf "$new_lines\n" >>/tmp/dns.new.tmp
echo '###### END BONJOUR PRINTER CONFIGURATION #######' >>/tmp/dns.new.tmp
original_md5=$(md5sum "$dnsfile")
original_md5=${original_md5% *}
new_md5=$(md5sum "/tmp/dns.new.tmp")
new_md5=${new_md5% *}
if [ "$original_md5" != "$new_md5" ] ; then
mv /tmp/dns.new.tmp "$dnsfile"
/etc/init.d/dnsmasq restart
else
rm -rf /tmp/dns.new.tmp
fi
}
if [ -e /tmp/printer_hotplug_lock ] ; then exit ; fi
touch /tmp/printer_hotplug_lock
count=5
while [ ! -e /sys/kernel/debug/usb/devices ] && [ $count -gt 0 ] ; do
sleep 1
count=$(( $count - 1 ))
done
if [ ! -e /sys/kernel/debug/usb/devices ] ; then
rm -rf /tmp/printer_hotplug_lock
exit
fi
p910nd_enabled=$(uci get p910nd.@p910nd[0].enabled 2>/dev/null)
p910nd_printer_name=$(uci get p910nd.@p910nd[0].printer_name 2>/dev/null)
printer="Unknown Printer"
if [ -n "$printer" ] ; then
if [ "$p910nd_enabled" != "1" ] || [ "$p910nd_printer_name" != "$printer" ] ; then
uci set p910nd.@p910nd[0].enabled="1"
uci set p910nd.@p910nd[0].printer_name="$printer"
uci commit
/etc/init.d/p910nd enable
/etc/init.d/p910nd stop >/dev/null 2>&1
/etc/init.d/p910nd start
fi
domain=$(uci get dhcp.@dnsmasq[0].domain)
hostname=$(uci get system.@system[0].hostname)
revip=$(uci get network.lan.ipaddr | sed 's/\./ /g' | awk ' { print "0."$3"."$2"."$1 ; }')
dnsmasqConfLines=""
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=b._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=db._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=r._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=dr._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=lb._dns-sd._udp.$revip.in-addr.arpa,$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=_services._dns-sd._udp.$domain,_pdl-datastream._tcp.$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nptr-record=_pdl-datastream._tcp.$domain,$hostname._pdl-datastream._tcp.$domain\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\nsrv-host=Gargoyle._pdl-datastream._tcp.$domain,$hostname.$domain,9100\n")
dnsmasqConfLines=$(printf "${dnsmasqConfLines}\ntxt-record=$hostname._pdl-datastream._tcp.$domain,ty=$printer,product=($printer),usb_MDL=$printer,txtvers=1,qtotal=1,priority=20\n")
update_dnsmasq_conf "/etc/dnsmasq.conf" "$dnsmasqConfLines"
#after we've found a printer we're done -- for now, only one printer at a time
elif [ "$p910nd_enabled" != "0" ] ; then
uci set p910nd.@p910nd[0].enabled=0
uci set p910nd.@p910nd[0].printer_name=""
uci commit
/etc/init.d/p910nd stop >/dev/null 2>&1
fi
rm -rf /tmp/printer_hotplug_lock
After Editing and refresh this window appeared for less than a second (I had to use a screen recorder to capture it)
https://ibb.co/Xz1pGm5
But After restarting the Router it worked !
https://ibb.co/s9gWtRq
I thought the problem is gone , but after trying to print test page from PC (port configured yesterday as per this guide
https://www.gargoyle-router.com/wiki/do ... ed_printer , the page just go the print queue page for half a second and then disappear as if its already printed successfully , but the printer does not print any thing .
Deleted the port and reconfigured it again now the page go to the print Queue and stay there with status "printing" for a minute or two then failed .
For reminding : the printer driver works very good at this PC , I have printed 3 pages yesterday to check .