Saturday, 29 November 2014

Network Printer with CUPS in a Raspberry Pi

Short story: I was tired of having to skpe or mail files to the secretary for her to print it in my behalf,  and working in a highly tech-oriented company, it was embarrasing, so the Raspberry Pi came to the rescue once again...

Sources:

Bartbania
Libre Geek

Install CUPS:

sudo apt-get install avahi-daemon cups cups-pdf python-cups
Once installed (it will take a while) add our user to the lpadmin group, in this case I'm assuming the default user "pi".

sudo usermod -a -G lpadmin pi

Install Samba and dependencies to make the Printer accessible over the network:

sudo apt-get install samba libncurses5-dev bridge-utils

Then edit the configuration file to enable network printing and sharing the printer, below are the most interesting lines in my configuration file:

pi@raspberrypi ~ $ sudo cat /etc/cups/cupsd.conf

# Allow remote access
Port 631

# Enable printer sharing and shared printers.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseRemoteProtocols CUPS dnssd
BrowseAddress 192.168.1.255
BrowseLocalProtocols CUPS dnssd
DefaultAuthType Basic
WebInterface Yes
ServerName 192.168.1.28

<Location />
 Order Deny,Allow
 Deny From All
 Allow From 127.0.0.1
 Allow From 192.168.1.*
</Location>

<Location /admin>
  Order allow,deny
  Allow @Local
</Location>

<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @Local
</Location>

Then either reboot the Raspberry Pi or restart CUPS:

sudo service cups restart

And that should be all, next we need to add the printer connected to the Raspberry Pi over the USB port, the process should be straight-forward.  The CUPS driver provides a webserver accessible over the socket specified by the RPi's IP and Port assigned in the cupsd.conf file.



No comments: