3
# Provides: cloudprintd
4
# Required-Start: $network $local_fs $remote_fs cups
5
# Required-Stop: $remote_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: A service for sharing printers on Google Cloud Print
9
# Description: Share locally-defined CUPS printers with the Google
10
# Cloud Print service. The printers can be accessed
11
# locally or remotely by authorized users via multiple
15
# Author: David Steele <dsteele@gmail.com>
17
# Copyright 2014 David Steele <dsteele@gmail.com>
18
# This file is part of cloudprint
19
# Available under the terms of the GNU General Public License version 2 or later
22
PATH=/sbin:/usr/sbin:/bin:/usr/bin
25
DAEMON=/usr/sbin/cloudprintd
27
# Read configuration variable file if it is present
28
[ -r /etc/default/$DESC ] && . /etc/default/$DESC
32
for str in $EXCLUDE_LIST ; do \
33
INCLUDE_OPT="$INCLUDE_OPT -x $str";\
36
for str in $INCLUDE_LIST ; do \
37
INCLUDE_OPT="$INCLUDE_OPT -i $str";\
40
AUTHFILE=/var/lib/cloudprintd/authfile
41
PIDFILE=/var/run/$NAME.pid
42
DAEMON_ARGS="-d -u -a $AUTHFILE -p $PIDFILE $FAST_POLL $INCLUDE_OPT"
43
SCRIPTNAME=/etc/init.d/$DESC
45
# Exit if the package is not installed
46
[ -x $DAEMON ] || exit 0
48
# Lintian says don't load this vars.sh that was provided with this skeleton
50
# Replace with default values for the variables used.
51
## Load the VERBOSE setting and other rcS variables
52
#. /lib/LINTIANIGNOREinit/vars.sh
58
# Define LSB log_* functions.
59
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
60
. /lib/lsb/init-functions
63
# Function that starts the daemon/service
67
if [ ! -e $AUTHFILE ] ; then
68
echo "No authentication found - run 'service $DESC login' as root"
72
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \
73
--name $DESC --test > /dev/null \
75
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \
76
--name $DESC -- $DAEMON_ARGS \
82
rm -f $AUTHFILE || true
83
rm -f $AUTHFILE.sasl || true
85
echo "Accounts with 2 factor authentication require an application-specific password"
87
$DAEMON -c -u -a $AUTHFILE $INCLUDE_OPT
93
$DAEMON $DAEMON_ARGS -l
98
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $DESC
100
[ "$RETVAL" = 2 ] && return 2
101
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
102
[ "$?" = 2 ] && return 2
103
rm -f $PIDFILE || true
104
rm -f $PIDFILE.lock || true
110
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
113
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
114
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
118
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
121
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
122
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
132
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
134
restart|force-reload)
135
log_daemon_msg "Restarting $DESC" "$NAME"
142
1) log_end_msg 1 ;; # Old process is still running
143
*) log_end_msg 1 ;; # Failed to start
153
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|login|logout}" >&2