This guide will show you how to turn an Orange Pi Zero into a Google Cloud Print server.
Download Debian Jesse from Armbian.
Download Etcher, use it to write the Armbian image to the SDCard. A 4gb card turned out to be the perfect size.
Power the Orange Pi via micro USB and connect the serial port via a CP2012, or your favorite USB/Serial adapter.
On a Mac (or linux) you can use this screen command to connect to the serial terminal. Use your favorite Windows terminal emulator to connect with the same properties on Windows:
screen /dev/tty.SLAB_USBtoUART 115200 8N1 flow off
The default login is root
and the password is 1234
, you'll be required to change this on login
Once you've logged in and setup a new root password, run nmtui
to setup the wireless network, which will be working out of the box:
nmtui
Enter a connection name, SSID and password. Save, quit and your board should be connected to WiFi.
Update the package list and upgrade to the latest packages with:
apt-get update
apt-get upgrade -y
If you need to re-size your SDCard, maybe you copied an image from another size disk, after the initial boot, run:
update-rc.d firstrun defaults
shutdown -r now
And after the restart, you'll have a bigger disk. Don't worry, this won't delete anything.
Find a driver for your printer. Google around for linux
+ printer make and model
You can also try to apt-cache search epson
or whatever make of printer you have.
I found my printer drivers in:
apt-get install -y printer-driver-escpr
Install the CUPS print server
apt-get install -y cups cups-client cups-common cups-pdf
Edit the CUPS configuration to listen on the Orange Pi's IP (not just localhost):
/etc/cups/cupsd.conf
Change Listen localhost:631
-> Port 631
and then restart CUPS with service cups restart
This would be a good time to set a static IP or assigned IP for your Orange Pi via your router, so you can always find it by the same IP.
Then, open http://[Orange Pi IP]:631
in a browser on your network.
Add a user for cups administration. This adds the user pi
to the lpadmin
group:
usermod -a -G lpadmin pi
Install the dependencies
apt-get install -y gcc make build-essential libcups2-dev libavahi-client-dev git bzr bison
Install Go
# install gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# install go 1.4 (required for 1.6)
gvm install go1.4.3
# use go 1.4
gvm use go1.4
# install go 1.6
gvm install go1.6.4
# use 1.6
gvm use go1.6
# check go version
go version
Install Google Cloud Print Connector with (including the ...
)
go get github.com/google/cloud-print-connector/...
This will install the binaries in /root/.gvm/pkgsets/go1.6.4/global/bin/
, which we can add to the system path if so desired.
gcp-connector-util
gcp-cups-connector
Now run ./gcp-connector-util init
and follow the guided prompts.
Start the service with
./gcp-cups-connector --config-filename gcp-cups-connector.config.json --log-to-console
And check https://www.google.com/cloudprint/#printers to see if your printer is available.
Finally edit gcp-cups-connector.config.json
and choose your logging location.
To start the service on boot, use this awesome little script by Vincze Janos Istvan
Save this to some location, like /opt/gcp/startup.sh
. You will probably need to mkdir -p /opt/gcp
first.
#!/bin/bash
BINDIR=/root/.gvm/pkgsets/go1.6.4/global/bin
IFS='
'
ps aux| grep -v grep | grep -q gcp-cups-connector
if [ $? -eq 0 ]
then
echo "Already running"
exit 0
fi
OK=0
while [ $OK -eq 0 ]
do
YEAR=$( date +%Y )
if [ $YEAR -gt 2015 ]
then
echo ok
OK=1
$BINDIR/gcp-cups-connector --config-filename $BINDIR/gcp-cups-connector.config.json
else
echo "Sleep for 1 secs"
sleep 1
fi
done
Add the following line to /etc/rc.local
to run the script on startup:
/opt/gcp/startup.sh &
Documentation for the board is here: http://linux-sunxi.org/Xunlong_Orange_Pi_Zero#Powering_the_board