Skip to content

Instantly share code, notes, and snippets.

@andredumas
Created June 27, 2014 02:10
Show Gist options
  • Save andredumas/790c487aad89d8a21ab0 to your computer and use it in GitHub Desktop.
Save andredumas/790c487aad89d8a21ab0 to your computer and use it in GitHub Desktop.
Headless Google Cloud Print Upstart script and a partial supporting recipe
# NOTE: This is partially complete and not ready for use, watch out for <user> tokens!
# Requires:
# * Printer drivers installed and registered with CUPS
# * Chrome installation (36 Beta was required at the time due to https://code.google.com/p/chromium/issues/detail?id=375841#c6)
# * A Generated "Service State" file (Instructions https://support.google.com/a/answer/2906017?hl=en)
package "cups"
service "cups" do
action [:enable, :start]
end
link "/etc/init.d/google-cloud-print" do
to "/lib/init/upstart-job"
end
cookbook_file "/etc/init/google-cloud-print.conf" do
owner "root"
group "root"
mode "0644"
source "/etc/init/google-cloud-print.conf"
action :create
notifies :restart, 'service[google-cloud-print]'
end
cookbook_file "/home/andre/.config/google-chrome/Service State" do
owner "<user>"
group "<user>"
mode "0600"
source "/home/<user>/config/google-chrome/Service State"
action :create
notifies :restart, 'service[google-cloud-print]'
end
service "google-cloud-print" do
provider Chef::Provider::Service::Upstart
action [:enable, :start]
end
#
# Upstart script for google-cloud-print.
#
# Usage:
# start google-cloud-print
# stop google-cloud-print
# restart google-cloud-print
#
description "google-cloud-print"
author "Andre Dumas"
version "1.0"
env USER="<user>"
env GROUP="<group>"
env WORKING_DIR="/home/$USER/.config/google-chrome"
start on (filesystem and net-device-up IFACE!=lo)
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 077
expect daemon
exec start-stop-daemon --chuid $USER:$GROUP --background -S -x /opt/google/chrome-beta/chrome -- --type=service --enable-cloud-print-proxy --no-service-autorun --noerrdialogs --user-data-dir=$WORKING_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment