A mobile lifestyle is a way of life these days. We have devices in our pockets, and the cloud is becoming more of a household resource than it ever was. How often did you open an email on your mobile device (tablet, phone, etc) only to find that you really needed to go your laptop or desktop to print that email, or website? Surely that moment can be a frustrating inconvenience, but with cloud printing, not any more!
By setting up cloud printing, you can put any printer online and make it shareable with others or your various devices and simply print from them like you do on your full service PC. This can also make faxing a thing of the past (if it isn’t already) by sharing your printer with someone else using the sharing capabilities of the cloud.
In my solution, I use Google’s cloud printing technology as well as some of my own technology running in a Linux VM (virtual machine). In this way, my printers can “go to sleep” and I don’t have to leave a computer running just for the sake of this convenience, yet they remain available in the cloud – willing and able, ready to serve. With Google’s cloud print, I can:
- Share any printer anywhere in the world on any device
- Manage print jobs from anywhere
- Queue print jobs if my print server is offline – they print as soon as the server is back online again
- make ANY printer (cloud based or not) accessible to any device – no need to buy expensive “cloud ready” printers or worry about compatibility with certain applications
- connect the CUPS (Common Unix Print Server) to google, making hosted printers available to the cloud
I already have a Linux home server that runs many VMs that run various services for our home; (PBX phone system, DLNA server, Filesharing, local caching DNS, business applications, database, & automation tools). Why not add a local print server and connect it to the Google Cloud?
Here’s how I did it:
First, install the required software to build a connector. I added this to a VM I already have running on my server (I use Ubuntu, but use any Linux you like). Install the opensource chromium browser and a X virtual frame buffer (the frame buffer is needed because I run the server headless and it has no installed GUI, so the framebuffer fakes a screen for the browser to draw and therefore run):
sudo apt-get install chromium-browser
sudo apt-get install xvfb
We now create the kickoff script that will be used to start the browser automatically and then background the process, thereby creating a “service” that is used as a Google Cloud Print connector. We save and then set the execute bit to make the script executable. Notice how I am forcing the program to run as “john”. I do this because I don’t want it running as root – this would open up nasty security implications – please don’t be “that guy” who runs everything as root – it’s really stupid and invites serious risk of abuse by hackers or malicious software:
su john -c “/usr/bin/xvfb-run –server-args=’-screen 1, 1024x768x16′ /usr/bin/chromium-browser –no-startup-window > /dev/null &“
chmod +x gcpstart.sh
Once we’ve set it executable, we must now call it via /etc/rc.local so it starts anytime the VM is booted:
But WAIT! we’re not done just yet! We need to install the CUPS print server so we can make the Linux system talk to local printers. We install CUPS as follows:
sudo apt-get install cups
Once CUPS is installed, you then add printers to CUPS as local printers. CUPS has a nice webUI for managing printers so you can do this all in a web browser on a headless server. Just point your browser to https://ip.of.cups.server:631 and you are in business once you allow access to the CUPS interface by making a few simple config modifications to CUPS. (CUPS setup and admin is not the scope of this article, so please refer to Google for how to setup CUPS).
Once your printers are added to CUPS, you then need to tell chromium-browser about them and log the browser into your Google Account. This is the part that connects your CUPS hosted printers to your Google cloud. You need to launch chromium-browser at least once to set this up. I did this from my Linux workstation by SSH’ing into the VM server with the X forwarding flag set and launching the browser on the command line as the unprivileged user I intend to run the service as:
ssh -X email@example.com (where john is the unprivileged user)
By running it once in this way, the browser executes on the VM but draws remotely on my workstation so I can graphically setup the browser, get it signed into my Google account, and then tell Google about my printers. Once you “sign in” the browser to your google account, you then go into the advanced settings to add your local printers to the cloud – the rest is intuitive:
Once you’ve registered your printers, you can then close the browser and reboot the VM and the script you used to call it on boot in /etc/rc.local will start chromium-browser as an unprivileged user in headless mode – thereby creating a connector service. At this point, any mobile device within your Google cloud account can now see the printers and print directly to them from anywhere!