User Tools

Site Tools


chromebooks:cloudprint_cups

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
chromebooks:cloudprint_cups [2013/11/14 14:53]
tschulz created
chromebooks:cloudprint_cups [2013/11/14 15:09] (current)
tschulz [Startup Script]
Line 27: Line 27:
 This starts the cloudprint service if you go to the [[https://​www.google.com/​cloudprint?​user=0#​printers|Cloud Print Control Panel]] as user **user@domain.com** you should see the printers from your local cups server. ​ This command will not return the terminal so we will need to add a script for that. This starts the cloudprint service if you go to the [[https://​www.google.com/​cloudprint?​user=0#​printers|Cloud Print Control Panel]] as user **user@domain.com** you should see the printers from your local cups server. ​ This command will not return the terminal so we will need to add a script for that.
 ===== Startup Script ===== ===== Startup Script =====
-<file bash /etc/init.d/​cloudprintproxy>+<file bash /scripts/cloud_print.sh>
 #!/bin/sh #!/bin/sh
-### BEGIN INIT INFO 
-# Provides: ​         cloudprintproxy 
-# Required-Start: ​   cups $network $syslog 
-# Required-Stop: ​    cups $network $syslog 
-# Default-Start: ​    2 3 4 5 
-# Default-Stop: ​     0 1 6 
-# Short-Description:​ Google Cloud Print Proxy 
-# Description: ​      ​Starts a Google Cloud Print Proxy 
-### END INIT INFO 
  
-# Author: Jeff Rebeiro ​<jeff@rebeiro.net>+/​opt/​google/​chrome/​chrome --type=service --enable-cloud-print-proxy --no-service-autorun --noerrdialogs --user-data-dir=/​etc/​cloudprint/​ & 
 +</file>
  
-PATH=/sbin:/usr/​sbin:/​bin:/​usr/​bin +<file bash /scripts/restart_cloudprint.sh> 
-DESC="​Google Cloud Print Proxy"​ +#!/bin/sh
-NAME=cloudprintproxy +
-DAEMON=/​opt/​google/​chrome/​chrome +
-CHROMEPROFILE="/​etc/​cloudprint/​cp/"​ +
-DAEMON_ARGS="​--type=service --enable-cloud-print-proxy --no-service-autorun --noerrdialogs --user-data-dir=${CHROMEPROFILE}"​ +
-PIDFILE=/​var/​run/​$NAME.pid +
-SCRIPTNAME=/etc/init.d/$NAME+
  
-# Exit if the package is not installed +restart() 
-[ -x "​$DAEMON"​ ] || exit 0 +{       ​killall ​-9 chrome 
- +        ​sleep ​
-# Read configuration variable file if it is present +        /scripts/cloud_print.sh
-[ -r /​etc/​default/​$NAME ] && . /​etc/​default/​$NAME +
- +
-# Exit if the Cloud Print configuration is not present +
-[ -r "​${CHROMEPROFILE}/​Service State" ] || exit 0 +
- +
-# Load the VERBOSE setting and other rcS variables +
-. /​lib/​init/​vars.sh +
- +
-# Define LSB log_* functions. +
-# Depend on lsb-base ​(>= 3.2-14to ensure that this file is present +
-# and status_of_proc is working. +
-. /​lib/​lsb/​init-functions +
- +
-+
-# Function that starts the daemon/​service +
-+
-do_start() +
-+
- # Return +
- # ​  0 if daemon has been started +
- # ​  1 if daemon was already running +
- # ​  if daemon could not be started +
- +
- # Ensure CUPS is running +
- ​lpstat &> ​/dev/null || return 2 +
- +
- # Test if daemon is already running +
- ​start-stop-daemon --start --quiet --pidfile $PIDFILE -m --exec $DAEMON --test > /dev/null \ +
-  || return 1 +
- +
- # Start daemon +
- ​start-stop-daemon --start --quiet --pidfile $PIDFILE -m -b --exec $DAEMON -- \ +
-  $DAEMON_ARGS \ +
-  || return 2+
 } }
  
-+restart
-# Function that stops the daemon/​service +
-+
-do_stop() +
-+
- # Return +
- # ​  0 if daemon has been stopped +
- # ​  1 if daemon was already stopped +
- # ​  2 if daemon could not be stopped +
- # ​  other if a failure occurred +
- ​killall chrome +
- ​start-stop-daemon --stop --quiet --retry=TERM/​30/​KILL/​5 --pidfile $PIDFILE --name $NAME +
- ​RETVAL="​$?"​ +
- [ "​$RETVAL"​ = 2 ] && return 2 +
- # Wait for children to finish too if this is a daemon that forks +
- # and if the daemon is only ever run from this initscript. +
- # If the above conditions are not satisfied then add some other code +
- # that waits for the process to drop all resources that could be +
- # needed by services started subsequently. ​ A last resort is to +
- # sleep for some time. +
- ​start-stop-daemon --stop --quiet --oknodo --retry=0/​30/​KILL/​5 --exec $DAEMON +
- [ "​$?"​ = 2 ] && return 2 +
- # Many daemons don't delete their pidfiles when they exit. +
- rm -f $PIDFILE +
- ​return "​$RETVAL"​ +
-+
- +
-case "​$1"​ in +
-  start) +
- [ "​$VERBOSE"​ != no ] && log_daemon_msg "​Starting $DESC" "​$NAME"​ +
- ​do_start +
- case "​$?"​ in +
-  0|1) [ "​$VERBOSE"​ != no ] && log_end_msg 0 ;; +
-  2) [ "​$VERBOSE"​ != no ] && log_end_msg 1 ;; +
- ​esac +
- ;; +
-  stop) +
- [ "​$VERBOSE"​ != no ] && log_daemon_msg "​Stopping $DESC" "​$NAME"​ +
- ​do_stop +
- case "​$?"​ in +
-  0|1) [ "​$VERBOSE"​ != no ] && log_end_msg 0 ;; +
-  2) [ "​$VERBOSE"​ != no ] && log_end_msg 1 ;; +
- ​esac +
- ;; +
-  status) +
-       ​status_of_proc "​$DAEMON"​ "​$NAME"​ && exit 0 || exit $? +
-       ;; +
-  ​restart+
- ​log_daemon_msg "​Restarting $DESC" "​$NAME"​ +
- ​do_stop +
- case "​$?"​ in +
-   ​0|1) +
-  do_start +
-  case "​$?"​ in +
-   0) log_end_msg 0 ;; +
-   1) log_end_msg 1 ;; # Old process is still running +
-   *) log_end_msg 1 ;; # Failed to start +
-  esac +
-  ;; +
-   *) +
-    # Failed to stop +
-  log_end_msg 1 +
-  ;; +
- ​esac +
- ;; +
-  *) +
- echo "​Usage:​ $SCRIPTNAME {start|stop|status|restart}"​ >&​2 +
- exit 3 +
- ;; +
-esac+
 </​file>​ </​file>​
 +<file bash /​etc/​rc.local>​
 +TERM="​xterm-color"​
 +SHELL="/​bin/​bash"​
 +XDG_SESSION_COOKIE="​5e1b8a057502aa735ff8be1600000177-1382969815.874167-799647066"​
 +USER="​root"​
 +MAIL="/​var/​mail/​root"​
 +PATH="/​usr/​local/​sbin:/​usr/​local/​bin:/​usr/​sbin:/​usr/​bin:/​sbin:/​bin:/​usr/​games"​
 +PWD="/​root"​
 +LANG="​en_US.UTF-8"​
 +SHLVL="​1"​
 +HOME="/​root"​
 +LOGNAME="​root"​
 +LESSOPEN="​| /​usr/​bin/​lesspipe %s"
 +LESSCLOSE="/​usr/​bin/​lesspipe %s %s"
 +_="/​usr/​bin/​env"​
  
 +ssh root@localhost "/​scripts/​restart_cloudprint.sh"​
  
 +exit 0
 +</​file>​
 +  * Lastly configure **key based ssh authentication**.
 +==== Notes ====
 +Using ssh was the only way I could get cloudprint to work on startup. ​ I also found that after a few hours cloud print would stop working. ​ I found if I restart chrome every hour the problem went away.  You might want to have cron run **ssh root@localhost "/​scripts/​restart_cloudprint.sh"​** every hour.
chromebooks/cloudprint_cups.1384462420.txt.gz · Last modified: 2013/11/14 14:53 by tschulz