sbs20 / scanserv

scanserv is a simple web-based UI for SANE which allows you to share a scanner on a network.
GNU General Public License v2.0
41 stars 13 forks source link

Scanserv and Sane via Entware on dd-wrt #2

Open ian5142 opened 7 years ago

ian5142 commented 7 years ago

I have installed sane via Entware (http://entware-3x.zyxmon.org/) on my D-Link 862L router. I have also installed php5, php5-cgi and lighttpd. I can serve php and html files from the router and I can view your scanserv page at router's-ip:81/scanserv . The problem is that it does not do preview or scan a page. Sane works fine via SANEtwain and via command line (scanimage -L and scanimage --test)

I did give the entire www folder that lighttpd is using chmod 775 several times.

My config.php is:

class Config { const IsTrace = false; const TraceLineEnding = "
\n"; const Scanimage = "/opt/bin/scanimage"; const Convert = "/opt/usr/local/sbin/convert"; const BypassSystemExecute = false; const OutputDirectory = "/opt/share/www/scanserv/output/"; const PreviewDirectory = "/opt/share/www/scanserv/preview/"; const MaximumScanWidthInMm = 216; const MaximumScanHeightInMm = 297; }

scanimage bin is actually located there. The problem is most likely that it can't find convert. I did search for convert in the default location (/usr/local/sbin/convert) and everywhere else. I can't find it. How do I install convert? Was it supposed to be installed with scanimage (when I installed sane-frontends and sane-backends and sane-libs)? If it was any idea on where I can find a copy of it for mips 3X kernel?

sbs20 commented 7 years ago

Hi Ian!

So a few things to consider:

  1. Convert lives in imagemagick - in Entware try opkg imagemagick
  2. However, "convert" is only used in the preview function to convert the tif to a jpg for the browser. So if scan isn't working either then it's not that.
  3. My guess is that which ever user lighttpd is running as doesn't have permission. According to this it appears to run as user "www".
  4. You may find instructions here to be useful
  5. Once you know the lighttpd user (my guess = www) then try sudo -i -u www and then run scanimage -L or if that fails then sane-find-scanner. If scanimage can't even find the scanner when running as lighttpd then most likely that user isn't a member of the scanner group or doesn't have access to the usb device - or both. Hopefully the instructions in point 4 will help (see also the Arch linux points too).

Good luck and let me know - and if it's ok try and keep a record of what you've done and we can make the instructions available to all!

Sam

ian5142 commented 7 years ago

First of all, yes I have imagemagick (opkg install imagemagick). The default user for lighttpd on entware is http, default group is www-data. I changed it in the config file for lighttpd to user www and group scanner. I created both user www and group scanner and gave the user same privileges as root.

The command sudo -g scanner -u www sane-find-scanner finds the USB scanner. The problem is: sudo -g scanner -u www scanimage -L does not find the scanner. scanimage bin has chmod 777 on it.

I have tried changing lighttpd user to root. According to ps | grep lighttpd, lighttpd is always running under root.

I made user www a member of group scanner

The zip file is my configs for sane and lighttpd. My subnet is 192.168.1.X subnet mask 255.255.255.0 dd-wrt config.zip

sbs20 commented 7 years ago

Good news about imagemagick.

Odd that it doesn't work with lighttpd running as root. I don't have a dd-wrt box to run this on so I'm limited to guessing, but it seems that the problem is running scanimage. The only similar problem I had was running it on a NAS and the httpd user had problems accessing the usb devices. I had to change the group owner of the device with chgrp scanner /proc/usb/003/003 - then again if you're already running as root one would imagine that that isn't an issue. Not only that but I found that at least sane-find-scanner and scanimage behaved consistently.

Have you made the sane-d accessible? chmod 644 /opt/etc/sane.d/*? That's the only other thing I can think of. Sorry!

gstrauss commented 7 years ago

@ian5142 check the lighttpd error.log and breakage.log to see if lighttpd has trouble running the script, or if the script sends trace to the breakage.log. Check your lighttpd.conf to see if you are running the expected PHP commands for the scanserv request.

Alternatively, set up lighttpd.conf with mod_proxy to proxy requests back to router's-ip:81/scanserv