Hi and welcome!

Setup CUPS on Raspberry PI 14-11-2014

CUPSRaspberry PI

Recently my printer EPSON SX105 died. I decided that it is a sign and after short trip to the nearest shop I bought Samsung M2022 laser printer.

Previously I used WIFI router TP-LINK N750 to connect the printer to the home network.

TP-LINK

This router has a build in "Print Server". So in theory you just need to connect printer to the router via USB cable and install special utility from TP-LINK called "USB Printer Controller" on client - and you get a "network" printer.

Well, not really network printer. This utility acts as a bridge or proxy. So first you need to setup the printer as local. You will send print jobs to this "local" printer, but utility will catch them and redirect to router’s printer.

As you can suppose this setup is very unstable, because it is not a real solution but rather some sort of hack. Utility often loses connection to the printer, or just don’t catch print jobs and require restart.

With Samsung this utility just stopped working at all.

After a small thinking I decided that this is a decent task for my Raspberry PI. In the Linux world for printing it is common to use CUPS (Common Unix Printer System). And guess what? CUPS works just fine on Raspbian.

Samsung M2022 + RaspberryPI

So lets go straight to setup. This is a common task and you can find a lot of tutorials on the Internet.

sudo apt-get -y install cups
/etc/cups/cupsd.conf
LogLevel warn
MaxLogSize 0
Listen 192.168.0.106:631
Listen /var/run/cups/cups.sock
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseLocalProtocols CUPS dnssd
DefaultAuthType Basic
WebInterface Yes

<Location />
  Order allow,deny
  Allow @local
  Allow 192.168.0.*
</Location>
<Location /admin>
  Order allow,deny
  Allow @local
</Location>
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @local
</Location>

<Policy default>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    Order deny,allow
  </Limit>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
<Policy authenticated>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    AuthType Default
    Order deny,allow
  </Limit>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
/etc/cups/client.conf
ServerName 192.168.0.106

This configuration slightly differs from default. It states:

  • The printer and admin console will be available by address 192.168.0.106:631.

  • It is possible to use web administration interface from the LAN.

After you add and configure the printer thru admin console, you should be able to add it as network printer on your computer. The link to printer:

http://192.168.0.106:631/printers/Samsung_M2020_Series

I am using this setup for a few weeks now and it works really great.

Important I do not why, but button "Share printer on the network" in admin console deletes all the data from cupsd.conf and in result you get empty configuration file and not working CUPS. I did not find the solution for this, so just do not press the button :)