Install google-cloud-print-connector on raspberry pi

The printing in chromebook is always a problem for a printer which does not support google cloud print. A possible solution is using a windows based chrome browser as a bridge to link between chromebook and the local printer, but the disadvantage is the windows computer must be always on.

I had a HP printer linked to a raspberry pi 3 running Raspbian, and there is a solution to make RPi as a google cloud printer connector.  Followings are steps installing the converter on raspbian (Debian Jessie). For more information, please refer to the website: https://github.com/google/cloud-print-connector/wiki/Build-from-source

In order to install the connector, Go 1.5.2 is required, however, Raspbian (Debian Jessie) only provides version 1.3?. New version of go can be installed as below (It’s tricky that version 1.5 can not be installed directly, version 1.4 should be installed first) :

  1. Install go 1.4
    $ git clone https://go.googlesource.com/go ~/go1.4
    $ cd ~/go1.4/src
    $ git checkout go1.4.3
    $ ./all.bash
  2. Install go 1.5
    $ git clone https://go.googlesource.com/go ~/go1.5
    $ cd ~/go1.5/src
    $ git checkout go1.5.2
    $ ./all.bash
  3. Config go –
    set work space
    $ echo 'export GOPATH=$HOME/go' >> ~/.bashrc
    set go install path
    $export GOROOT=$HOME/go1.5/go1.5
    $ echo 'PATH="$PATH:$GOROOT/bin"' >> ~/.bashrc
    $ source ~/.bashrc
    $ go version
    go version go1.5.2 linux/arm
  4. Build
    run command in ~/folder 
    $go get github.com/google/cloud-print-connector/...
  5. In folder ~/go/bin you should have two new binaries gcp-cups-connector and gcp-connector-util
  6. Create an unprivileged gcp system user:
    sudo useradd -s /usr/sbin/nologin -r -M cloud-print-connector
    

    Create /opt/cloud-print-connector:

    sudo mkdir /opt/cloud-print-connector
    

    Move the binaries to /opt/cloud-print-connector:

    sudo mv ~/go/bin/gcp-cups-connector /opt/cloud-print-connector
    
    sudo mv ~/go/bin/gcp-connector-util /opt/cloud-print-connector
  7. Make sure the binaries are executable:
    sudo chmod 755 /opt/cloud-print-connector/gcp-cups-connector
    
    sudo chmod 755 /opt/cloud-print-connector/gcp-connector-util
    

    Change the owner of the binaries to gcp:

    sudo chown cloud-print-connector:cloud-print-connector /opt/cloud-print-connector/gcp-cups-connector
    
    sudo chown cloud-print-connector:cloud-print-connector /opt/cloud-print-connector/gcp-connector-util
  8. Make a gcp config:
    sudo /opt/cloud-print-connector/gcp-connector-util init
  9. Make a gcp config:
    sudo /opt/cloud-print-connector/gcp-connector-util init
    

    Example configuration:

    "Local printing" means that clients print directly to the connector via local subnet,
    and that an Internet connection is neither necessary nor used.
    Enable local printing?
    y
    
    "Cloud printing" means that clients can print from anywhere on the Internet,
    and that printers must be explicitly shared with users.
    Enable cloud printing?
    y
    
    Retain the user OAuth token to enable automatic sharing?
    y
    
    User or group email address to share with:
    xxx@gmail.com
    
    Proxy name for this GCP CUPS Connector:
    MyPrinterName
    
    Visit https://www.google.com/device, and enter this code. I'll wait for you.
    XXXX-XXXX
    Acquired OAuth credentials for robot account
    
    The config file /home/pi/gcp-cups-connector.config.json is ready to rock.
    Keep it somewhere safe, as it contains an OAuth refresh token.
    

    Move the gcp config to /opt/cloud-print-connector/:

    sudo mv ~/gcp-cups-connector.config.json /opt/cloud-print-connector/
    

    Change the file permissions of the gcp config:

    sudo chmod 660 /opt/cloud-print-connector/gcp-cups-connector.config.json
    

    Change the owner of the gcp config to gcp:

    sudo chown cloud-print-connector:cloud-print-connector /opt/cloud-print-connector/gcp-cups-connector.config.json
  10. run $/opt/cloud-print-connector/gcp-cups-connector -config-filename /opt/cloud-print-connector/gcp-cups-connector.config.json
  11. In chromebook, add google cloud printer in setting – > advance
  12. done!

2 评论

发表回复