Closed andi-blafasl closed 11 years ago
if i recall the IDs can change nice find though, i will look into this, there are bigger fish to fry atm edit: 6 hours later, fish fryed, but it is late now
This seems to work quite nicely :)
chad@M4A79XTD-EVO:~$ scanimage -f "%d%n" plustek:libusb:003:004 hpaio:/usb/Deskjet_F4400_series?serial=CN05DC61TP05C5 chad@M4A79XTD-EVO:~$ lsusb -s 003:004 Bus 003 Device 004: ID 1606:0060 Umax Astra 3400/3450 chad@M4A79XTD-EVO:~$ cat /etc/udev/rules.d/40-scanner.rules SUBSYSTEMS=="usb", ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes", GROUP="www-data"
Edit: Made a bash script for making the rules, it could use testing
#!/bin/bash
rule="/etc/udev/rules.d/40-scanner.rules"
if [ "$USER" != "root" ];then
echo "You are not root, you need to be root for this to work."
exit
fi
md5=$(date +%s:%N | md5sum)
md5=${md5:0:32}
scanners=$(scanimage -f "%d%n" | grep 'libusb:')
for val in $scanners;do
usb=$(echo $val | sed -n "s/.*libusb:\([0-9]*\):\([0-9]*\)/\1:\2/p")
lsusb -s "$usb" | sed "s/.*ID \([0-9]*\):\([0-9]*\).*/SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"\1\", ATTRS{idProduct}==\"\2\", ENV{libsane_matched}=\"yes\", MODE:=\"666\"/" >> /tmp/$md5
chmod 666 /dev/bus/usb/$(echo "$usb" | sed 's/:/\//')
done
if [ -f /tmp/$md5 ];then
if [ -f $rule ];then
sumA=$(md5sum /tmp/$md5)
sumA=${sum:0:32}
sumB=$(md5sum $rule)
sumB=${sum:0:32}
if [ "$sumA" == "$sumB" ];then
echo "Good to go"
else
echo "You have rules, but something is different"
echo -e " \e[1;34m$rule\e[0m has:"
echo -e "\t\e[1;32m#---START-OF-FILE---\e[0m"
cat -n $rule
echo -e "\t\e[1;31m#----END-OF-FILE----\e[0m"
echo "These are the new rules:"
echo -e "\t\e[1;32m#---START-OF-FILE---\e[0m"
cat -n /tmp/$md5
echo -e "\t\e[1;31m#----END-OF-FILE----\e[0m"
echo -e "No action taken, you can edit \e[1;34m$rule\e[0m as you see fit"
fi
else
cp /tmp/$md5 $rule
fi
fi
rm /tmp/$md5
exit
Completed, See Downloads
made a new installer for it
EDIT:
Next version will make rules like this
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes", GROUP="lp"
That way the permissions are the same a a HP scanner which works out of the box with the PHP Scanner Server
EDIT:
Actually it will check if the lp
group exist and and if it does not it will use scanner
and if scanner does not exist it will mode
it to 666
Nice one! Works great.
Did the easy installer work on Debian Wheezy on the pi? or did you do the manual install
here my guide in Italian version : http://wiki.ubuntu-it.org/Server/PhpScannerServer
I did the manual installation not your easy installer, sorry.
Nice work, i do encourage people to use the manual install, you learn more that way
Did you run into any issues while following the instructions
in step 3 i no longer use tesseract-ocr-*
there are lots more of them than there were are 1st release and i made it auto detect languages
you may want to include tesseract-ocr-ita tesseract-ocr-ita-old
though, cause they are the Italian languages files for tesseract
You have a typo here sudo chown-R www-data /v
should be sudo chown -R www-data /v
there is a space after chown
You can get a URL for the scanner by running http://$(uname -n).local
but i don't think that URL works on a Windows XP system
Led to discovery an solution of issue #13
I have managed to enable access to my scanner by a simple UDEV-Rule.
Create the file 90-scanner.rules in /etc/udev/rules.d/ and the follow content
--8<---8<---8<---8<---
change device file permission to group scanner for sane access
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220d", SUBSYSTEMS=="usb", ACTION=="add", MODE="0664", GROUP="scanner"
--8<---8<---8<---8<---
Replace the Vendor-ID and Product-ID with your IDs from LSUSB output. Now, every time you connect your scanner the device node will be set to RW-RW-R-- rights with owner ROOT and group SCANNER. You can add all your users who should be able to scan to the scanner group.
Works great on Debian Wheezy on my Rasperry Pi and should be update safe and would not open any big security hole.
If you google for udev-Rules for scanner access some people suggest to change the default rule for every usb-device to be in mode 666 and redo the change after every update to the udev packet facepalm