Using scanner buttons on Ubuntu with scanbd (part 2/2)

8 Comments

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

Few days ago, I described how to build and install scanbd. Now, it needs to be configured to perfectly suit the scanner it’s used with. As you’ll see, you have some very interesting possibilities with a four buttons scanner such as the EPSON Perfection V200 Photo.

First, install xinetd which will allow to use scanbd as a wrapper:

apt-get install xinetd

 
Create a sane-port service configuration file /etc/xinetd.d/sane-port with the following content:

service sane-port
{
socket_type = stream
server = /usr/local/bin/scanbd
server_args = -m -c /usr/local/etc/scanbd/scanbd.conf
protocol = tcp
user = saned
group = saned
wait = no
disable = no
}

 
Stop saned service

service saned stop

 
and disable it as it will now be launched through xinetd/scanbd. Just modify /etc/default/saned as follows:

RUN=no

 
Now, restart xinetd:

service xinetd restart

 
It should return:

 * Stopping internet superserver xinetd                             [ OK ]
 * Starting internet superserver xinetd                             [ OK ]

 
Next, create your own /usr/local/etc/scanbd/scanbd.conf file (keep the original file, just in case…) to describe the available actions (buttons) on your scanner model. The configuration file I created for the EPSON Perfection V200 Photo is available here.
 
Copy the scanbd.debian initialisation script located in scanbd source directory to /etc/init.d/scanbd and install its link using the following command:

update-rc.d scanbd defaults

 
Make sure all the backends except the SANE network backend are commented out in /etc/sane.d/dll.conf:

net

 
Uncomment the following line at the end of /etc/sane.d/net.conf:

localhost

 
Comment out the SANE backend for EPSON scanners in /etc/sane.d/dll.d/iscan:

#epkowa

 
Create a /usr/local/etc/scanbd/dll.conf file including the following line:

epkowa

 
Copy (don’t move!) /etc/sane.d/epkowa.conf to /usr/local/etc/scanbd/epkowa.conf.

Copy /etc/sane.d/saned.conf to /usr/local/etc/scanbd/saned.conf.

Then, verify that you have no access list entry configured in /etc/sane.d/saned.conf and add one in /usr/local/etc/scanbd/saned.conf to restrict access to local subnet hosts only (adapt to your own network configuration):

192.168.253.0/24

 
Now that scanbd is configured for both local and LAN hosts access, let’s continue with the most interesting part of the configuration: The script executed when each button is pressed. You’ll find here the one I use to manage the 4 buttons “Start”, “Copy”, “Email” and “Pdf” available on the EPSON Perfection V200 Photo. Save it as /usr/local/etc/scanbd/actions.sh and make it executable with a chmod 755 command.

In association with my scanner model, this script offers the following functions:
– Single page scan to JPEG
– Instant copy (scan to printer)
– Email creation with JPEG or multi-page PDF attachment
Multi-page PDF creation
All this using only the scanner front buttons!

The buttons usage is explained at the beginning of the script file, along with some variables (such as SCANDIR and PRINTER) you’ll have to modify according to your needs. Also make sure to have imagemagick and mpack packages installed. If not, install them:

apt-get install imagemagick mpack

 
Scanbd setup is complete now but I added a last refinement. Having xinetd always running on the server, just because of the scanner buttons, bothered me (I don’t have any other service depending on xinetd). I updated the existing udev rule (previously added to assign the scanner to the saned group) to automatically start/stop the internet superserver when turning on/off the scanner, respectively. All you have to do is to replace your existing “scanner” udev rule (mine was /etc/udev/rules.d/40-saned.rules) with the following file and disable xinetd, scanbd and saned startup scripts using the following three commands:

update-rc.d xinetd disable
update-rc.d scanbd disable
update-rc.d saned disable

 
If ever you have other services depending on xinetd and only want to stop the scanbd service, take a look at the chkconfig package.

That’s all Folks!

(Thanks for the help, bro. You’re da man!)


For further reading, see scanbd website and Gentoo udev Guide.

Advertisements

Using scanner buttons on Ubuntu with scanbd (part 1/2)

Leave a comment

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

After the successful installation of my scanner, I discovered with frustration that the four hard buttons of the device were not supported by the default backend. Few days later, after thorough searches, I installed an old scanner buttons polling daemon called scanbuttond and found out it was conflicting with saned, the daemon used to share the scanner over the network.

I was about to give up when I came across the scanbd project. This clever daemon opens, polls, locks the scanner and then acts as a kind of proxy which manages all further access to the device by any other application, thus avoiding possible conflicts.

I had a hard time installing and configuring scanbd but it was worth it. I’ll describe the steps I followed in two separate posts. Today’s post will explain how to compile scanbd with EPSON Perfection V200 Photo support and my next post will be about its complete configuration, including a nice script which perfectly manages the scanner four buttons.
 
So, let’s start by downloading the latest source code from scanbd project website:

wget link_to_latest_scanbd_source_code

 
Make sure the /usr/local/src directory exists and is writable by your primary user account. Then, unpack the file:

tar xf scanbd_source.tgz -C /usr/local/src

 
Scanbd can use SANE or scanbuttond backends. Unfortunately, the epkowa (SANE) backend which is used to control the EPSON Perfection V200 Photo does not fully support the front buttons. Therefore, I had to look for a compatible backend… and I found one, thanks to www.linotux.ch.

To patch scanbd to use this specific backend, cd to the directory where you extracted scanbd source code and modify scanbuttond/backends/Makefile by adding references to epson_vphoto as follows:

all: epson_vphoto.so mustek.so plustek.so plustek_umax.so snapscan.so ...

epson_vphoto.so: epson_vphoto.c epson_vphoto.h

 
Then, download the epson_vphoto backend and extract it to the same current scanbuttond/backends directory.

Finally, add the following line at the end of scanbuttond/backends/meta.conf:

epson_vphoto

 
OK, we’re almost ready to compile but, as Ubuntu does not come by default with the compilation tools required, we’ll need to install them first:

apt-get install build-essential checkinstall

 
And while we’re at it, let’s also install some specific packages needed to compile or use scanbd:

apt-get install libconfuse-dev libusb-dev libudev-dev libdbus-1-dev dbus

 
Now, build

USE_SCANBUTTOND=yes make -e clean all

 
and install:

USE_SCANBUTTOND=yes checkinstall --deldesc=yes

 
When asked for, you can enter the following packaging informations (modify according to your version):

This package will be built according to these values:

0 -  Maintainer: [ Wilhelm Meier <wilhelm.meier@fh-kl.de> ]
1 -  Summary: [ Scanner button daemon ]
2 -  Name:    [ scanbd ]
3 -  Version: [ 1.2 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Misc ]
7 -  Architecture: [ amd64 ]
8 -  Source location: [ scanbd-1.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ scanbd ]

Enter a number to change any of them or press ENTER to continue:

 
VoilĂ ! Package is built and install is done. We’ll take care of the complete configuration in part 2.

That’s all Folks!


For further reading, see scanbd website and CompilingEasyHowTo of the Community Ubuntu Documentation.

Monitoring a UPS with NUT on Ubuntu Server

2 Comments

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

Running a Linux server without taking care of possible power failures is not a good idea. A power outage can be disastrous for your valuable data if the server is not connected to an emergency power system, notified of the outage and able to properly shutdown the system while on battery power. With an Ubuntu home server, this kind of situations can be handled using a UPS (Uninterruptible Power Supply) and Network UPS Tools (NUT).

First, install NUT:

apt-get install nut

 
Next, declare your UPS in /etc/nut/ups.conf (I use an MGE Protection Center 675 so don’t forget to modify the driver value according to your own UPS model, as found in NUT documentation):

[ups]
	driver = usbhid-ups
	port = auto
	desc = "MGE UPS SYSTEMS Protection Center 675"

 
In /etc/nut/nut.conf, set NUT daemon to run in standalone mode. It’s the mode to use on the machine to which the UPS is connected and when this same machine also monitors the UPS:

MODE = standalone

 
In /etc/nut/upsd.conf, bind a listening port to the LAN interface if you want to allow other LAN hosts to monitor the UPS through upsd, the UPS network daemon. If not, just keep the first line:

LISTEN 127.0.0.1
LISTEN 192.168.253.2

 
Set the permissions for upsd in /etc/nut/upsd.users. Only the users (one section = one user) listed in this file will be allowed to read the UPS state:

[upsmonitor]
	password = password1
	upsmon master

[monuser]
        password = password2
        upsmon slave

(the [monuser] section is optional and only added here to allow a LAN host to monitor the UPS state over the network)
 
Now, configure the upsmon daemon. Its role is to communicate with upsd to know the UPS status and send specific commands when some events occur. Modify /etc/nut/upsmon.conf as follows:

MONITOR ups@localhost 1 upsmonitor password1 master

 
Finally, make sure to modify the permissions of all NUT configuration files:

chown root:nut /etc/nut/*
chmod 640 /etc/nut/*

 
Now that everything is setup, let see some useful commands.

To start NUT manually (upsd and upsmon daemons simultaneously):

service nut start

 
To check both daemons status:

service nut status

 
To launch the UPS driver:

upsdrvctl start

 
To know the UPS status:

upsc ups

(modify ups according to the section name you used in /etc/nut/ups.conf)
 
To test the server behavior in case of power outage, use the following command:

upsmon -c fsd

 
If the UPS is connected to mains, the server will stop and then restart (don’t forget to set your BIOS power management to “Always on”). If the UPS is unplugged, the server will restart only after reconnection to mains.
 
One last thing: If you have a “BUS= will be removed in a future udev version” error at system boot, see https://bugs.launchpad.net/ubuntu/+source/nut/+bug/692171 for a solution.
 
That’s all Folks!


For further reading, see NUT website.

Installing a network printer with CUPS

Leave a comment

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

Having a network-capable printer greatly ease its installation and everyday use. It can be remotely managed or shared on the local network without having to setup (and keep turned on) a computer as a printer server for instance. It can also be located wherever you wish (especially if you use wireless or PLC networking technologies to connect the printer to the network) and, best of all, it’s very easy to install on Ubuntu Server Edition.

First thing to do is to install CUPS which handles printing on Ubuntu:

apt-get install cups

 
Next, we need to modify its configuration file /etc/cups/cupsd.conf.
Instruct the CUPS server to listen on the LAN interface only (reference to the loopback address can be commented out):

#Listen localhost:631
Listen 192.168.253.2:631

 
Set the authentication and permissions parameters in all the ‹Location› sections to limit access to sudoers only:

AuthType Default
Require user @admin
Order allow,deny
Allow @LOCAL

 
The following option can also be modified if you don’t want CUPS to share (publish) the printer:

DefaultShared no

 
Save the changes and restart CUPS:

service cups restart

 
Now, you can continue the installation using the web interface available at https://cups_server_hostname:631/admin. Just click on the “Add printer” button and follow the instructions. CUPS should automatically find your printer on the network. When asked to enter the printer’s make and model, best would be to provide a PPD file (driver) instead. You can often find this file by extracting the official Windows driver (at least that’s what I’ve done for my Dell 1700n printer).

Once all steps are completed, print a test page:

lpstat -p -d

 
If everything went fine, you should soon hear the printer coming to life.

That’s all Folks!


For further reading, see CUPS website.

Sharing a scanner over the network with Linux

Leave a comment

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

A scanner installed on the server and only accessible locally through the command-line is not very user-friendly. Sharing it over the network to use it from Linux with GUI, Windows or Mac OS X clients would be a great step forward. That’s what we’ll do today.

First, make sure sane-utils is installed by issuing:

apt-show-versions -a sane-utils

 
If not, install it with the apt-get install command.

Then, configure saned, the daemon used to allow remote clients to access the scanner over the network. Modify /etc/default/saned to enable it:

RUN=yes

 
Edit /etc/sane.d/saned.conf and add the following line to restrict access to local subnet hosts only (adapt to your own network configuration):

192.168.253.0/24

 
Restart the daemon

service saned restart

 
and make sure it will start automatically at boot up:

update-rc.d saned defaults

 
Now you should be able to remotely access the scanner on the local network using, for example, SaneTwain on a Windows client. Download and install it following the instructions on the website and you’ll quickly hear the carriage moving and see your first preview image on the screen.

That’s all Folks!


For further reading, see XSane website. It’s an open source graphical scanning frontend which can be installed on multiple platforms and perfectly works with saned.

Installing a scanner on Ubuntu Server Edition

6 Comments

Successfully tested on Ubuntu Server 10.04 LTS 64-bit

Today’s mission is to install a scanner (EPSON Perfection V200 Photo) which will be used locally on the server. As you’ll see, it’s pretty easy.

Download the driver and other packages specific to the EPSON Perfection V200 Photo scanner at EPSON Support website:

iscan_*.ltdl7_amd64.deb
iscan-data_*_all.deb
iscan-plugin-gt-f670_*_amd64.deb

Install them:

dpkg -i iscan*.deb

 
In case of dependencies errors during the installation, correct them using the following command:

apt-get -f install

 
Verify the presence of the /etc/sane.d/dll.d/iscan file which should contain a single line:

epkowa

 
epkowa is the name of the backend used by SANE to control the scanner. If the iscan file is not there, edit /etc/sane.d/dll.conf and add or uncomment the following line:

epkowa

 
Now set access permissions to the device by creating a new file /etc/udev/rules.d/40-saned.rules with a udev rule which will automatically assign the scanner to the saned group

# Epson Perfection V200 Photo
ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012e",GROUP="saned"

(ATTRS values can be found using the lsusb command)

and reload the ACL:

udevadm trigger

 
Each local user will have to be added to the saned group before he can access the scanner:

usermod -aG saned username

 
One last modification can also be done to /etc/sane.d/epkowa.conf but it seems not to be mandatory:

usb
#scsi

 
OK, we’re almost done! Let see if we can access the scanner:

sane-find-scanner

 
should return something similar to:

found USB scanner (vendor=0x04b8 [EPSON], product=0x012e [EPSON Scanner]) 
at libusb:002:003

 
Great! Now we can install a command-line frontend named scanimage which is included in the sane-utils package

apt-get install sane-utils

 
and try if it sees the scanner:

scanimage -L

 
If everything went fine, the answer should look like:

device `epkowa:interpreter:002:003' is a Epson Perfection V200 flatbed sca
nner

 
To scan for real, place a document in the scanner and type:

scanimage --format=tiff > test.tif

 
The scan is made using all the default parameters of the device and placed in the current directory.

That’s all Folks!


For further reading, see the SANE project website.