Search:  
Gentoo Wiki

CUPS

This article is still a Stub. You can help Gentoo-Wiki by expanding it.

Image:Gentoo_tux.png

Base Install

  1. What is Gentoo?
  2. About
  3. Preparation
  4. Partitioning
  5. Configuring
  6. Stage Progression
  7. Kernel
  8. Bootloader
  9. Test
  10. Converting from or to a non-Gentoo distribution
  11. Troubleshooting
  12. Maintaining

Configuration

Base Extras

Server

Desktop

Other Articles

edit

Contents

First note

There is already plenty amount of cups howtos. This is meant to be easy to read and generic.

Install

Installation is actually really easy; emerge cups. NOTE: There is a special group of printers which will need the use flag below.

You also should enable use flags for features you might need in future, such as jpeg, png and tiff.

Okay, ready? Just install, then

# emerge cups -pv
# echo "net-print/cups jpeg ldap php png ppds tiff" >> /etc/portage/package.use
# emerge cups

Configuration

Configuration is quite easy too. You don't need change cups configs, just using web interface is enough.

First you should add the init script to the default runlevel:

# rc-update add cupsd default

Then start CUPS:

# /etc/init.d/cupsd start

Then just navigate with a web browser to http://localhost:631 (631 is default port of cupsd)

# links http://localhost:631

NOTE: by default the cups web server doesn't work outside of the localhost.

By modifying the cups config you can allow other users browse cups's "site". It's not wise to do so, but the easiest (and the least secure) way is just replace all references to localhost in the config.

Allow localhost

to...

Allow all

This seems to not be enough nowadays: You may need change

Listen localhost:631

to...

Listen *:631

This way everyone can go to your cups http server. This is pretty safe inside a LAN, but you can always give just some computers access using

Listen 192.168.0.2:631

This port is the default cups port, so if you want use other port, remember to change this setting too!

NOTE: On the other hand, if you want to install cups for your personal machine (i.e. not a server), and don't want to share cups, or any of your printers, then put the following lines in /etc/cups/cupsd.conf

# Disable printer browsing on the network.
Browsing Off
BrowseOrder allow,deny
BrowseAllow @LOCAL

# Listen only for local connections
Listen localhost:631

Adding a printer

Local Printer

Finally the section you have waited for.

Just go to http://localhost:631 with your browser and go to Administration (https://localhost:631/admin/) section.

Note: Initial connection to the Administration tab might timeout. This is because CUPS needs to generate an SSL certificate. Try reloading the URL once or twice after the initial time-out

If your printer is USB and you're a little lucky, CUPS will automagically see the printer and offer you a link to add it. Follow the prompts (you should just have to name it) and you're golden. If you printer is USB, you need to have USB Printer support in your kernel, or it will not show up or be available. If you're asked for Model/Driver or Model/Manufacturer and your printer isn't listed you can check if your printer is listed on http://www.linuxprinting.org and try emerging net-print/foomatic-db-ppds or net-print/foomatic-filters-ppds. After a restart of cups you should be able to add your printer without providing a ppd file.

Otherwise, you can manually add it.

About device: If your printer is connected to lpt port, make sure that you have parallel port support and parallel printer support in kernel. I compiled them as modules. They're named as parport and lp.

If you are using a USB->Parallel adapter, you will want to do the following:

Network Printer

CUPS

Adding a network printer available on a remote CUPS server is fairly straight forward. When adding a printer to CUPS, it defaults to allowing access to it remotely. The only requirement is a valid userid & password.

Point your browser at CUPS on the print server http://printserver:631 and click on the Printers links to see what printers are available. Then click on the printer you want to add to your local workstation. This will give you the URL you'll need for your local CUPS. The url format is server:port/printers/printer_name . Something like http://printserver:631/printers/HP_psc_1310_series_USB_MY4261D0ZPO2_HPLIP

On your local CUPS ( http://localhost:631 )

Mini-HOWTO written by Smar

You might ask yourself what printer drivers you need where. I cannot really say how this is supposed to be done correctly, but it would make sense to filter data between your source file (say, a PDF) and your printer only once. I nevertheless installed the printer on both the print server's CUPS (with the LPT port as the printer's connection) and on my notebook/workstation with the method described above (or with ipp, as you chose). As the data that my workstation now sent was already filtered (i.e. already in printer-specific raw data), CUPS on print server side complained about not knowing how to cope with application/octet-stream data. If you look at CUPS' web interface on workstation side, the error looks like this

 print_job: Unsupported format 'application/octet-stream'!

The same most certainly has to be true for a windows box (I don't have one) that tries to print at the printserver's printer.

(Could someone more knowledgable comment on how this whole thing really works? i.e. would this work as well if one would only filter on client/workstation side and install a "generic", "raw" printer on print server side so data is more or less only forwarded to the hardware port (LPT, USB, etc..)? Feel free to delete these questions once there is a definitive explanation here)

The solution to coping with "Unsupported format 'application/octet-stream'" however is to allow the print server to accept raw (i.e. prefiltered) data.

Edit /etc/cups/mime.convs on print server side and uncomment

 application/octet-stream        application/vnd.cups-raw        0       -

Alternatives

Filters

Cups comes with some nice filters, enabling you to print a lot of files directly from the command line. E.g. lpr foo.pdf will convert foo.pdf to a PostScript file and then send it to the printer. You can look in /etc/cups/mime.convs for a list of conversions cups will perform automatically.

Adding filters is easy. The following shows you how to add a filter enabling you to print DVI files directly via "lpr". First we tell cups to use the filter dvitops (which we will write below) to convert DVI files to PostScript files. Put the following lines in /etc/cups/local.convs.

# Local DVI to PostScript filter for CUPS
application/x-dvi application/postscript 50 dvitops

Next we tell cups to treat any file starting with hex bytes F702 as a DVI file. Put the following in /etc/cups/local.types.

# Local MIME definition for DVI files
application/x-dvi dvi string(0,<F702>)

Finally we write the filter dvitops. Put the following in /usr/libexec/cups/filter/dvitops

#!/bin/bash
# CUPS filter to process DVI files using dvips
# If "dvips" is in a non-standard location (e.g. in the texlive path), then
# you should add that location to your PATH first.
#PATH="$PATH:/usr/local/texlive/2007/bin/i386-linux"

jobid="$1"
user="$2"
title="$3"
copies="$4"
options="$5"
file="$6"

if [[ -z $file ]]; then
    dvips -R -q -C $copies -f
else
    # Call dvips quietly, securely and with output to stdout
    dvips -R -q -C $copies -o - "$file"
fi

And make it executable.

chmod a+rx /usr/libexec/cups/filter/dvitops

That's it. Restart cups, and you can just "lpr" DVI files.

External links

Retrieved from "http://www.gentoo-wiki.info/CUPS"

Last modified: Mon, 06 Oct 2008 10:58:00 +0000 Hits: 12,639