CUPS
From Gentoo Linux Wiki
This article is still a Stub. You can help Gentoo-Wiki by expanding it.
|
Contents |
[edit] First note
There is already plenty amount of cups howtos. This is meant to be easy to read and generic.
[edit] Install
Installation is actually really easy; emerge cups. NOTE: There is a special group of printers which will need the use flag below.
- ppds Adds support for many printers
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
[edit] 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
[edit] Adding a printer
[edit] 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.
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.
Otherwise, you can manually add it.
- Name it
- Device
- Make
- Model
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:
- Add your printer by selecting a different connection type (since usb and parallel will not be listed)
- edit the file /etc/cups/printers.conf
- change the DeviceID line to read DeviceID = parallel:/dev/usb/lp0
- ( Note that is is "parallel:" NOT "usb:" - the USB part is handled by the usb drivers. To CUPS it should show up as a parallel port. CUPS doesn't know to look for USB->Parallel adapters, but if you manually configure it, it will work)
[edit] Network Printer
[edit] 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 )
- Add a Printer
- Name it
- Device
- Select Internet Printing Protocol (http)
- Device URI
- Plug in the URL you snagged from the print server. e.g. http://printserver:631/printers/HP_psc_1310_series_USB_MY4261D0ZPO2_HPLIP
- Select the Make
- Select the Model
Mini-HOWTO written by Smar
[edit] Alternatives
- foomatic-gui - tool for configuring and managing printers (as simple and straight-forward as localhost:631)
[edit] 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.

