Print Server on RaspberryPI 1

  • Tutorial

image


For a long time I was tormented by the idea of ​​an old RPI to make a print server (remote printing and scanning) and finally I got to this.


We assume that we have a set of RPI, a flash drive with Raspbian, a Wi-Fi adapter, an HP LaserJet Pro 1102 printer, an HP Deskjet F2180 MFP, and a USB hub. The main machine (BB) that will use the print server lives on Linux (however, differences in use for Windows will be minimal).


Training


In order not to connect to the RPI via wire, we will add auto-connect via wi-fi. To do this, insert the USB flash drive from Raspbian into the BB and go to / boot, where we will create 2 files:


  • ssh (empty) - enables ssh;
  • wpa_supplicant.conf, which contains data for connecting to our wi-fi:
    network={
       ssid="YOUR_SSID"
       psk="YOUR_PASSWORD"
       key_mgmt=WPA-PSK
    }

We insert the USB flash drive into the RPI, the Wi-fi adapter (directly, and not into the hub - it is for printers), we connect the power. After a minute, we climb onto the wi-fi router to find out the address that it issued the RPI, and go to it via SSH.


Let's configure the RPI by running raspi-config .


If you are not comfortable with IP addressing, you can configure the host name to work through mDNS. We write the name in / etc / hostname and in / etc / hosts for example, printserver.local, commit the changes to sudo /etc/init.d/hostname.sh and go to reboot. After rebooting, RPI through mDNS will be available at printserver.local. For Linux, mDNS works by default, and for Windows you need to install the Bonjour print service .


We put CUPS


Let's do it first


sudo apt-get update && sudo apt-get upgrade

Then install CUPS


sudo apt-get install cups

In order to manage printers in CUPS, you need to add some user to the lpadmin group. We assume that we work under the default user - pi. Here we add it:


sudo usermod -a -G lpadmin pi

Since the print server is located in the home network, we allow it to be accessible to everyone, and then restart:


sudo cupsctl --remote-any 
sudo /etc/init.d/cups restart

In principle, we have a ready-made CUPS, which is available at https: //printserver.local: 631 / and, probably, it will work for many printers like that, but not in our case.


HP LaserJet Pro 1102 Printer


For this beast, no suitable drivers were found in the standard delivery. I had to install a driver from foomatic:


sudo apt-get install printer-driver-foo2zjs-common printer-driver-foo2zjs

and select another driver for this printer in the admin panel : HP LaserJet 1022 Foomatic / foo2zjs-z1


He began to print, but very slowly and sometimes stupidly skipping my commands.


I left the configuration with this driver, because it allows you to print from any device without installing drivers, albeit for a long time and mostly in one page. For large volumes, I had to configure a different configuration of the same printer in CUPS.


We will use xinetd to emulate an HP-jetdirect printer. First, install xinetd:


sudo apt-get install xinetd

Now configure our service for xinetd:


service hp-jetdirect
{
       socket_type = stream
       protocol = tcp
       wait = no
       user = pi #наш юзер здесь
       server = /usr/bin/lp
       server_args = -d HP_LaserJet_Professional_P1102_direct -o raw 
       groups = yes
       disable = no
}

HP_LaserJet_Professional_P1102_direct is what the jet-direct-printer profile will be called in CUPS.
Run:


/etc/rc.d/xinetd start

Now go to the admin panel and create a new printer named HP_LaserJet_Professional_P1102_direct. The main thing is to choose this driver: Local Raw Printer. As a result, our printer will have a network link https: //printserver.local: 631 / printers / HP_LaserJet_Professional_P1102_direct , which must be used when setting up printing on the BB.


All, now the main thing is to install the driver on the machine with which we print and voila - large volumes print at normal speed.


HP Deskjet F2180 Scanner


Actually, this is not a scanner, but an MFP, but I use it only as a scanner.
For scanning we need sane


sudo apt-get install sane

Then we’ll use the utility, which allows us to see what we have for the scanners


sudo sane-find-scanner

In the case of the HP Deskjet F2180 scanner, you most likely will not see it.
We install drivers from hp:


sudo apt-get install hplip

Now repeat the search:


found USB scanner (vendor=0x0424, product=0xec00) at libusb:001:003

Отлично, теперь попробуем глянуть может ли наш сканер принимать команды


pi@PrintServer:~ $ sudo scanimage -L 
device `hpaio:/usb/Deskjet_F2100_series?serial=CN78R4R3PB04TK' is a Hewlett-Packard Deskjet_F2100_series all-in-one

то есть, на RPI сканер работает.


Далее на удаленном линухе установливаем sane и sane-utils и лезем в /etc/sane.d/net.conf, чтобы в самом низу добавить адрес RPI


К сожалению, на удаленной машине sudo scanimage -L выдал.


No scanners were identified. If you were expecting something different, check that the scanner is plugged in, turned on and detected by the sane-find-scanner tool (if appropriate). Please read the documentation which came with this software (README, FAQ, manpages).

Просканировав порты RPI увидел, что порт 6566 закрыт. Что ж, еще немного поконфигурируем xinetd


sudo nano /etc/xinetd.d/sane-port

Вставляем


service sane-port
{
       socket_type = stream
       port       = 6566
       wait       = no
       user       = root
       group      = root
       server     = /usr/sbin/saned
       disable    = no
}

Выходим, сохраняем и рестартим сервис:


sudo service xinetd restart

Повторяем на удаленной машине sudo scanimage -L и видим


device `net:printserver.local:hpaio:/usb/Deskjet_F2100_series?serial=CN78R4R3PB04TK' is a Hewlett-Packard Deskjet_F2100_series all-in-one

То что надо. Можно приступать к сканированию запустив xsane.


Спасибо за внимание.


upd praeivisxsane есть под Windows


Использовано


http://www.raspberry-pi-geek.com/Archive/2013/01/Converting-the-Raspberry-Pi-to-a-wireless-print-server
https://samhobbs.co.uk/2014/07 / raspberry-pi-print-scanner-server
https://blog.johanv.org/posts/old/node-195.html
http://lib.ru/unixhelp/linuxset.txt


Also popular now: