[sane-devel] help with getting scanbd and interactive scanner tools working together
Ron Young
rly1 at embarqmail.com
Tue Jan 2 05:30:07 GMT 2024
Apologies, I sent the wrong notes for the saned only configuration
notes, new files are attached.
Also, what doesn't work in the scanbd configuration is that the sane
tools/gscan2pdf/simple-scan doesn't see the scanner.
-ron
On 1/1/24 15:02, Ron Young wrote:
> Hi Everyone:
>
> I have been working on getting scanbd and sane working together on
> my x86 linuxmint 21.2 system with fujitsu snapscan ix500.
>
> How I want things to work is as follows:
>
> 1) using scanbd, press the single start button on the ix500 scanner,
> the adf contents should be scanned in /var/spool/scan without any
> further action.
>
> 2) Either as root or a normal user in the scanner group, using common
> tools (i.e. gscan2pdf, simple-scan, scanimage, etc)... scan the
> documents
> in the ix500.
>
> my current configuration works for either 1 or 2 but NOT at the same
> time. I would be very happy if I could do either of them as needed
> without
> having to change anything.
>
> I have attached two files that contain the detailed steps I used
> for each of the above configurations. sane-devel-saned is the
> configuration of saned without scanbd, and sane-devel-scanbd is the
> config with scanbd active.
>
> Of course they contain shell commands, that I cut and paste from my
> notes during testing, I don't run them directly as shell scripts.
>
> Any help that you can give me would be appreciated!
>
> -ron
>
-------------- next part --------------
#
# linuxmint 21.2 (mate desktop) - fujitsu snapscan ix500
#
# restore system status to a clean state for scanner testing sane only, no scanbd
# with this configuration, sane tools, gscan2pdf, and simple-scan work for both root and normal
# users
rm -rf /etc/scanbd/*
apt-get purge -y scanbd sane libsane-common libsane1 sane-airscan sane-utils simple-scan gscan2pdf
apt-get install -y sane libsane-common libsane1 sane-airscan sane-utils simple-scan gscan2pdf
#
# configure sane for network and local scanner access
#
cat >/etc/sane.d/dll.conf << EOF
net
fujitsu
EOF
cat > /etc/sane.d/net.conf <<EOF
connect_timeout = 3
localhost
EOF
cat > /etc/udev/rules.d/40-scanner.rules << EOF
SUBSSTEMS=="usb", ATTRS{idVendor}="04c5". ATTRS{idProduct}=="132b", ENV{libsane_matched}="yes", GROUP="scanner"
EOF
sudo /etc/init.d/udev restart
systemctl daemon-reload
-------------- next part --------------
#
# linuxmint 21.2 (mate desktop) - fujitsu snapscan ix500
#
#restore system status to a clean state for scanner testing sane with scanbd
# with this configuration, currently, sane tools, gscan2pdf, and simple-scan doesn't work for
# interactive root and normal users. BUT it does work if the button is pushed through scanbd
#
rm -rf /etc/scanbd/*
apt-get purge -y scanbd sane libsane-common libsane1 sane-airscan sane-utils simple-scan gscan2pdf
apt-get install -y scanbd sane libsane-common libsane1 sane-airscan sane-utils simple-scan gscan2pdf
#
# create a separate network sane scanner in addition to a local scanner
#
mkdir /etc/scanbd/sane.d
cp -r /etc/sane.d/* /etc/scanbd/sane.d/
#
# Modify /etc/sane.d/dll.conf so that it includes only the "net" directive and the local scanner (for
# simple-scan and other utilities)saned
cat > /etc/sane.d/saned.conf << EOF
192.168.0.0/16
127.0.0.0/8
EOF
cat >/etc/sane.d/dll.conf << EOF
net
fujitsu
EOF
cat > /etc/sane.d/net.conf <<EOF
connect_timeout = 3
localhost
EOF
ed /etc/scanbd/sane.d/dll.conf <<EOF
g/^net/s/^/#/p
w
q
EOF
ed /etc/inetd.conf <<EOF
g/^sane-port/s/^/#/p
w
q
EOF
ed /etc/scanbd/scanbd.conf << EOF
/SANE_CONFIG_DIR/s/\/etc\/scanbd/\/etc\/scanbd\/sane.d/p
g/test.script/s//scan.sh/p
g/^ *user *= saned/s/saned/root/p
w
q
EOF
mkdir /etc/scanbd/scripts && cp /home/ron/scan.sh /etc/scanbd/scripts
cat <etc/scanbd/scripts/scan.sh << EOF
#!/bin/bash
# Author: Rastislav David <rasto at ynet.sk>
scan_dir=/var/spool/scan
datetime=`date +%F_%H%M%S`
filename="scan-$datetime"
send_to=email at address.com
case "$SCANBD_ACTION" in
pdf)
logger -t "scanbd: $0" "$SCANBD_ACTION - scanning and converting to ps"
scanimage -d "$SCANBD_DEVICE" --mode Color --resolution 150 --depth 16 |
convert -density 150 - "$scan_dir/$filename.ps"
logger -t "scanbd: $0" "$SCANBD_ACTION - converting ps to pdf"
ps2pdf -sPAPERSIZE=a4 "$scan_dir/$filename.ps" "$scan_dir/$filename.pdf"
rm "$scan_dir/$filename.ps"
;;
scan)
scanimage -d "$SCANBD_DEVICE" --resolution 300 --mode Gray --format=tiff > "$\
scan_dir/$filename.tiff"
;;
copy)
logger -t "scanbd: $0" "$SCANBD_ACTION - scanning"
scanimage -d "$SCANBD_DEVICE" --resolution 300 --depth 16--format=tiff > "$sc\
an_dir/$filename.tiff"
# | convert -density 300 - $scan_dir/$filename.ps
logger -t "scanbd: $0" "$SCANBD_ACTION - printing"
lp "$scan_dir/$filename.tiff"
rm "$scan_dir/$filename.tiff"
;;
email)
logger -t "scanbd: $0" "$SCANBD_ACTION - scanning and converting to ps"
scanimage -d "$SCANBD_DEVICE" --mode Color --resolution 150 --depth 16 |
convert -density 150 - "$scan_dir/$filename.ps"
logger -t "scanbd: $0" "$SCANBD_ACTION - converting ps to pdf"
ps2pdf -sPAPERSIZE=a4 "$scan_dir/$filename.ps" "$scan_dir/$filename.pdf"
logger -t "scanbd: $0" "$SCANBD_ACTION - sending pdf"
(cat <<EOCAT
Document scanned on Canon LiDE 110
EOCAT
uuencode "$scan_dir/$filename.pdf" "$scan_dir/$filename.pdf" ) | mail -a
"From: Canon scanner <some at email.sk>" -s "Document $filename" "$send_to"
rm "$scan_dir/$filename.ps"
rm "$scan_dir/$filename.pdf"
;;
*)
logger -t "scanbd: $0" "Unhandled action request."
;;
esac
exit 0
EOF
chmod 755 /etc/scanbd/scripts/scan.sh
#
# enable/disable udev rules for testing
#
# enable start
cat > /etc/udev/rules.d/40-scanner.rules << EOF
SUBSSTEMS=="usb", ATTRS{idVendor}="04c5". ATTRS{idProduct}=="132b", ENV{libsane_matched}="yes", GROUP="scanner"
EOF
# enable end
# disable start
cat > /etc/udev/rules.d/40-scanner.rules << EOF
# Fujitsu SnapScan ix500
SUBSSTEMS=="usb", ATTRS{idVendor}="04c5". ATTRS{idProduct}=="132b",
ENV{libsane_matched}="yes", GROUP="scanner",
ENV{ID_VENDOR_ID}=="04c5", ENV{ID_MODEL_ID}=="132b", ACTION=="add",
RUN+="/usr/sbin/service inetutils-inetd start",
RUN+="/usr/bin/scanimage -L", RUN+="/usr/sbin/service scanbd start"
ENV{ID_VENDOR_ID}=="04c5", ENV{ID_MODEL_ID}=="132b", ACTION=="remove",
RUN+="/usr/sbin/service scanbd stop", RUN+="/usr/sbin/service
inetutils-inetd stop"
EOF
#disable end
sudo /etc/init.d/udev restart
systemctl stop scanbm.socket
systemctl disable scanbm.socket
systemctl daemon-reload
systemctl unmask scanbd
systemctl enable scanbd
systemctl restart scanbd
More information about the sane-devel
mailing list