Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Install

Gregory P. Smith edited this page Jan 17, 2016 · 29 revisions

Summary

These instructions will result in sharing all printers on your CUPS server with Chrome, on the local subnet (mDNS broadcast domain) only. This is accomplished without creating/maintaining any config file.

If you need to share the printers with Google Cloud Print clients on Android, iOS, or Windows, or if you need to share the printers with clients not on the local subnet, then visit Configuration after completing these steps.

Get the binaries

Visit https://github.com/google/cups-connector/releases/latest to download binaries for your platform. Note: There is a dependency on Openssl 1.0.0 for the binary builds. Not all distros ship with Openssl 1.0.0

If binaries aren't available for your platform, then visit Build from source.

Extract the .tar.gz file you downloaded. You'll find two binary executables:

  • gcp-cups-connector
  • shares CUPS printers
  • processes print jobs
  • runs for long periods of time
  • gcp-cups-connector-util
  • create a new config file
  • upgrade a config file after a release
  • delete all printers
  • collect monitoring values

Prepare the platform

Before running the connector, make sure that the necessary client libraries are available: CUPS and Avahi. Also, git and bzr are needed to fetch some Go dependencies.

If your distro is based on Debian (Ubuntu, Raspbian, Mint, others) then this one-liner will get all dependencies:

$ sudo apt-get install cups libcups2 libavahi-client3 avahi-daemon libsnmp30

OpenSUSE 13.2:

$ sudo zypper install cups cups-libs libavahi-client3 avahi libsnmp30

CentOS and friends:

$ sudo yum install cups cups-libs avahi-libs avahi net-snmp-libs

The binaries don't work on Fedora currently, due to a difference in the name of libcrypto.so. You can still Build from source.

Run the CUPS Connector

You will also need a running CUPS server. The standard CUPS client configuration applies:

Run the connector:

$ gcp-cups-connector

The connector logs to to /tmp/connector.INFO (and others) by default.

If any printers are installed on the CUPS server, then they should now be available locally via Google Cloud Print. Test this by printing to the newly available GCP printer(s) from a Chrome browser.

Ctrl-C will stop the connector.

Create a config file

This would be a good time to create a config file, if you need one.

Run automatically on boot

There are many ways to do this. This is a simple method that works well for a Raspberry Pi.

Edit /etc/rc.local, add these lines at the end, just before exit 0

# CUPS Connector:
#   sleep:                                      hack to wait for the network interface to come up
#   su ... pi:                                  run as user "pi"
#   --login:                                    environment similar to "pi" instead of "root"
#   --command:                                  run this thing
#   /home/pi/cups-connector/gcp-cups-connector: thing to run
#   &:                                          run the command "in the background"
sleep 60
su --login --command /home/pi/cups-connector/gcp-cups-connector pi &

For Ubuntu I made the following method of managing the connector with Upstart (Ubuntu 14 and earlier):

Create a file /etc/init/gcp.conf

description "Google Cloud Print daemon to forward requests to CUPS"
author      "LinuxLover <[email protected]>"

start on (local-filesystem and net-device-up)
stop on runlevel [!2345]

respawn
exec su -l -s /bin/sh -c "/opt/gcp_cups_connector/gcp-cups-connector -config-filename /etc/gcp_cups_connector/gcp-cups-connector.config.json" gcp

For Ubuntu using systemd (Ubuntu 15 and later):

Create a file /etc/systemd/system/gcp.service

[Unit]
Description="Google Cloud Print daemon to forward requests to CUPS"
Documentation="https://github.com/google/cups-connector"

[Service]
Type=simple
ExecStart=/opt/gcp_cups_connector/bin/gcp-cups-connector -config-filename /opt/gcp_cups_connector/gcp-cups-connector.config.json

[Install]
WantedBy=multi-user.target

Note:

  • I used the Installing-on-Raspberry-Pi page for most of the setup.
  • And since I have as default a PDF printer, I had to create a directory for user gcp
  • And assign myself to the gcp group to read the /home/gcp/PDF folder
sudo mkhomedir_helper gcp
sudo chmod -R 776 /home/gcp
sudo adduser YOURNAME gcp