1*5e7646d2SAndroid Build Coastguard Worker#!/bin/sh 2*5e7646d2SAndroid Build Coastguard Worker# 3*5e7646d2SAndroid Build Coastguard Worker# Startup/shutdown script for CUPS. 4*5e7646d2SAndroid Build Coastguard Worker# 5*5e7646d2SAndroid Build Coastguard Worker# Copyright © 2007-2013 by Apple Inc. 6*5e7646d2SAndroid Build Coastguard Worker# Copyright © 1997-2007 by Easy Software Products, all rights reserved. 7*5e7646d2SAndroid Build Coastguard Worker# 8*5e7646d2SAndroid Build Coastguard Worker# Licensed under Apache License v2.0. See the file "LICENSE" for more 9*5e7646d2SAndroid Build Coastguard Worker# information. 10*5e7646d2SAndroid Build Coastguard Worker# 11*5e7646d2SAndroid Build Coastguard Worker 12*5e7646d2SAndroid Build Coastguard Worker#### OS-Dependent Information 13*5e7646d2SAndroid Build Coastguard Worker 14*5e7646d2SAndroid Build Coastguard Worker# 15*5e7646d2SAndroid Build Coastguard Worker# Linux chkconfig stuff: 16*5e7646d2SAndroid Build Coastguard Worker# 17*5e7646d2SAndroid Build Coastguard Worker# chkconfig: 235 99 00 18*5e7646d2SAndroid Build Coastguard Worker# description: Startup/shutdown script for CUPS. 19*5e7646d2SAndroid Build Coastguard Worker# 20*5e7646d2SAndroid Build Coastguard Worker 21*5e7646d2SAndroid Build Coastguard Worker# 22*5e7646d2SAndroid Build Coastguard Worker# NetBSD 1.5+ rcorder script lines. The format of the following two 23*5e7646d2SAndroid Build Coastguard Worker# lines is very strict -- please don't add additional spaces! 24*5e7646d2SAndroid Build Coastguard Worker# 25*5e7646d2SAndroid Build Coastguard Worker# PROVIDE: cups 26*5e7646d2SAndroid Build Coastguard Worker# REQUIRE: DAEMON 27*5e7646d2SAndroid Build Coastguard Worker# 28*5e7646d2SAndroid Build Coastguard Worker 29*5e7646d2SAndroid Build Coastguard Worker 30*5e7646d2SAndroid Build Coastguard Worker#### OS-Dependent Configuration 31*5e7646d2SAndroid Build Coastguard Worker 32*5e7646d2SAndroid Build Coastguard Workercase "`uname`" in 33*5e7646d2SAndroid Build Coastguard Worker *BSD*) 34*5e7646d2SAndroid Build Coastguard Worker IS_ON=: 35*5e7646d2SAndroid Build Coastguard Worker ECHO=echo 36*5e7646d2SAndroid Build Coastguard Worker ECHO_OK=: 37*5e7646d2SAndroid Build Coastguard Worker ECHO_ERROR=: 38*5e7646d2SAndroid Build Coastguard Worker ;; 39*5e7646d2SAndroid Build Coastguard Worker 40*5e7646d2SAndroid Build Coastguard Worker Darwin*) 41*5e7646d2SAndroid Build Coastguard Worker . /etc/rc.common 42*5e7646d2SAndroid Build Coastguard Worker 43*5e7646d2SAndroid Build Coastguard Worker if test "${CUPS:=-YES-}" = "-NO-"; then 44*5e7646d2SAndroid Build Coastguard Worker exit 0 45*5e7646d2SAndroid Build Coastguard Worker fi 46*5e7646d2SAndroid Build Coastguard Worker 47*5e7646d2SAndroid Build Coastguard Worker IS_ON=: 48*5e7646d2SAndroid Build Coastguard Worker ECHO=ConsoleMessage 49*5e7646d2SAndroid Build Coastguard Worker ECHO_OK=: 50*5e7646d2SAndroid Build Coastguard Worker ECHO_ERROR=: 51*5e7646d2SAndroid Build Coastguard Worker ;; 52*5e7646d2SAndroid Build Coastguard Worker 53*5e7646d2SAndroid Build Coastguard Worker Linux*) 54*5e7646d2SAndroid Build Coastguard Worker IS_ON=/bin/true 55*5e7646d2SAndroid Build Coastguard Worker if test -f /etc/init.d/functions; then 56*5e7646d2SAndroid Build Coastguard Worker . /etc/init.d/functions 57*5e7646d2SAndroid Build Coastguard Worker ECHO=echo 58*5e7646d2SAndroid Build Coastguard Worker ECHO_OK="echo_success" 59*5e7646d2SAndroid Build Coastguard Worker ECHO_ERROR="echo_failure" 60*5e7646d2SAndroid Build Coastguard Worker else 61*5e7646d2SAndroid Build Coastguard Worker ECHO=echo 62*5e7646d2SAndroid Build Coastguard Worker ECHO_OK=: 63*5e7646d2SAndroid Build Coastguard Worker ECHO_ERROR=: 64*5e7646d2SAndroid Build Coastguard Worker fi 65*5e7646d2SAndroid Build Coastguard Worker ;; 66*5e7646d2SAndroid Build Coastguard Worker 67*5e7646d2SAndroid Build Coastguard Worker *) 68*5e7646d2SAndroid Build Coastguard Worker IS_ON=/bin/true 69*5e7646d2SAndroid Build Coastguard Worker ECHO=echo 70*5e7646d2SAndroid Build Coastguard Worker ECHO_OK=: 71*5e7646d2SAndroid Build Coastguard Worker ECHO_ERROR=: 72*5e7646d2SAndroid Build Coastguard Worker ;; 73*5e7646d2SAndroid Build Coastguard Workeresac 74*5e7646d2SAndroid Build Coastguard Worker 75*5e7646d2SAndroid Build Coastguard Worker#### OS-Independent Stuff 76*5e7646d2SAndroid Build Coastguard Worker 77*5e7646d2SAndroid Build Coastguard Worker# 78*5e7646d2SAndroid Build Coastguard Worker# Set the timezone, if possible... This allows the scheduler and 79*5e7646d2SAndroid Build Coastguard Worker# all child processes to know the local timezone when reporting 80*5e7646d2SAndroid Build Coastguard Worker# dates and times to the user. If no timezone information is 81*5e7646d2SAndroid Build Coastguard Worker# found, then Greenwich Mean Time (GMT) will probably be used. 82*5e7646d2SAndroid Build Coastguard Worker# 83*5e7646d2SAndroid Build Coastguard Worker 84*5e7646d2SAndroid Build Coastguard Workerfor file in /etc/TIMEZONE /etc/rc.config /etc/sysconfig/clock; do 85*5e7646d2SAndroid Build Coastguard Worker if test -f $file; then 86*5e7646d2SAndroid Build Coastguard Worker . $file 87*5e7646d2SAndroid Build Coastguard Worker fi 88*5e7646d2SAndroid Build Coastguard Workerdone 89*5e7646d2SAndroid Build Coastguard Worker 90*5e7646d2SAndroid Build Coastguard Workerif test "x$ZONE" != x; then 91*5e7646d2SAndroid Build Coastguard Worker TZ="$ZONE" 92*5e7646d2SAndroid Build Coastguard Workerfi 93*5e7646d2SAndroid Build Coastguard Worker 94*5e7646d2SAndroid Build Coastguard Workerif test "x$TIMEZONE" != x; then 95*5e7646d2SAndroid Build Coastguard Worker TZ="$TIMEZONE" 96*5e7646d2SAndroid Build Coastguard Workerfi 97*5e7646d2SAndroid Build Coastguard Worker 98*5e7646d2SAndroid Build Coastguard Workerif test "x$TZ" != x; then 99*5e7646d2SAndroid Build Coastguard Worker export TZ 100*5e7646d2SAndroid Build Coastguard Workerfi 101*5e7646d2SAndroid Build Coastguard Worker 102*5e7646d2SAndroid Build Coastguard Worker# 103*5e7646d2SAndroid Build Coastguard Worker# Don't use TMPDIR environment variable from init script, as that can 104*5e7646d2SAndroid Build Coastguard Worker# cause cupsd to set TempDir to a user's temporary directory instead 105*5e7646d2SAndroid Build Coastguard Worker# of the default... 106*5e7646d2SAndroid Build Coastguard Worker# 107*5e7646d2SAndroid Build Coastguard Worker 108*5e7646d2SAndroid Build Coastguard Workerunset TMPDIR 109*5e7646d2SAndroid Build Coastguard Worker 110*5e7646d2SAndroid Build Coastguard Worker 111*5e7646d2SAndroid Build Coastguard Worker# 112*5e7646d2SAndroid Build Coastguard Worker# Make sure we have the standard program directories in the path 113*5e7646d2SAndroid Build Coastguard Worker# since some operating systems don't provide a standard path on boot-up... 114*5e7646d2SAndroid Build Coastguard Worker# 115*5e7646d2SAndroid Build Coastguard Worker 116*5e7646d2SAndroid Build Coastguard Workerif test "x$PATH" = x; then 117*5e7646d2SAndroid Build Coastguard Worker PATH="/bin:/usr/bin:/sbin:/usr/sbin" 118*5e7646d2SAndroid Build Coastguard Workerelse 119*5e7646d2SAndroid Build Coastguard Worker PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH" 120*5e7646d2SAndroid Build Coastguard Workerfi 121*5e7646d2SAndroid Build Coastguard Worker 122*5e7646d2SAndroid Build Coastguard Workerexport PATH 123*5e7646d2SAndroid Build Coastguard Worker 124*5e7646d2SAndroid Build Coastguard Worker# 125*5e7646d2SAndroid Build Coastguard Worker# See if the CUPS server (cupsd) is running... 126*5e7646d2SAndroid Build Coastguard Worker# 127*5e7646d2SAndroid Build Coastguard Worker 128*5e7646d2SAndroid Build Coastguard Workercase "`uname`" in 129*5e7646d2SAndroid Build Coastguard Worker SunOS*) 130*5e7646d2SAndroid Build Coastguard Worker pid=`ps -e | nawk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'` 131*5e7646d2SAndroid Build Coastguard Worker ;; 132*5e7646d2SAndroid Build Coastguard Worker Linux* | *BSD* | Darwin*) 133*5e7646d2SAndroid Build Coastguard Worker pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'` 134*5e7646d2SAndroid Build Coastguard Worker ;; 135*5e7646d2SAndroid Build Coastguard Worker *) 136*5e7646d2SAndroid Build Coastguard Worker pid="" 137*5e7646d2SAndroid Build Coastguard Worker ;; 138*5e7646d2SAndroid Build Coastguard Workeresac 139*5e7646d2SAndroid Build Coastguard Worker 140*5e7646d2SAndroid Build Coastguard Worker# 141*5e7646d2SAndroid Build Coastguard Worker# Start or stop the CUPS server based upon the first argument to the script. 142*5e7646d2SAndroid Build Coastguard Worker# 143*5e7646d2SAndroid Build Coastguard Worker 144*5e7646d2SAndroid Build Coastguard Workercase $1 in 145*5e7646d2SAndroid Build Coastguard Worker start | restart | reload) 146*5e7646d2SAndroid Build Coastguard Worker if $IS_ON cups; then 147*5e7646d2SAndroid Build Coastguard Worker if test -x /sbin/portrelease; then 148*5e7646d2SAndroid Build Coastguard Worker /sbin/portrelease cups 149*5e7646d2SAndroid Build Coastguard Worker fi 150*5e7646d2SAndroid Build Coastguard Worker 151*5e7646d2SAndroid Build Coastguard Worker if test "$pid" != ""; then 152*5e7646d2SAndroid Build Coastguard Worker kill -HUP $pid 153*5e7646d2SAndroid Build Coastguard Worker else 154*5e7646d2SAndroid Build Coastguard Worker prefix=@prefix@ 155*5e7646d2SAndroid Build Coastguard Worker exec_prefix=@exec_prefix@ 156*5e7646d2SAndroid Build Coastguard Worker @sbindir@/cupsd 157*5e7646d2SAndroid Build Coastguard Worker if test $? != 0; then 158*5e7646d2SAndroid Build Coastguard Worker $ECHO_FAIL 159*5e7646d2SAndroid Build Coastguard Worker $ECHO "cups: unable to $1 scheduler." 160*5e7646d2SAndroid Build Coastguard Worker exit 1 161*5e7646d2SAndroid Build Coastguard Worker fi 162*5e7646d2SAndroid Build Coastguard Worker fi 163*5e7646d2SAndroid Build Coastguard Worker $ECHO_OK 164*5e7646d2SAndroid Build Coastguard Worker $ECHO "cups: ${1}ed scheduler." 165*5e7646d2SAndroid Build Coastguard Worker fi 166*5e7646d2SAndroid Build Coastguard Worker ;; 167*5e7646d2SAndroid Build Coastguard Worker 168*5e7646d2SAndroid Build Coastguard Worker stop) 169*5e7646d2SAndroid Build Coastguard Worker if test "$pid" != ""; then 170*5e7646d2SAndroid Build Coastguard Worker kill $pid 171*5e7646d2SAndroid Build Coastguard Worker $ECHO_OK 172*5e7646d2SAndroid Build Coastguard Worker $ECHO "cups: stopped scheduler." 173*5e7646d2SAndroid Build Coastguard Worker fi 174*5e7646d2SAndroid Build Coastguard Worker ;; 175*5e7646d2SAndroid Build Coastguard Worker 176*5e7646d2SAndroid Build Coastguard Worker status) 177*5e7646d2SAndroid Build Coastguard Worker if test "$pid" != ""; then 178*5e7646d2SAndroid Build Coastguard Worker echo "cups: scheduler is running." 179*5e7646d2SAndroid Build Coastguard Worker else 180*5e7646d2SAndroid Build Coastguard Worker echo "cups: scheduler is not running." 181*5e7646d2SAndroid Build Coastguard Worker fi 182*5e7646d2SAndroid Build Coastguard Worker ;; 183*5e7646d2SAndroid Build Coastguard Worker 184*5e7646d2SAndroid Build Coastguard Worker *) 185*5e7646d2SAndroid Build Coastguard Worker echo "Usage: cups {reload|restart|start|status|stop}" 186*5e7646d2SAndroid Build Coastguard Worker exit 1 187*5e7646d2SAndroid Build Coastguard Worker ;; 188*5e7646d2SAndroid Build Coastguard Workeresac 189*5e7646d2SAndroid Build Coastguard Worker 190*5e7646d2SAndroid Build Coastguard Worker# 191*5e7646d2SAndroid Build Coastguard Worker# Exit with no errors. 192*5e7646d2SAndroid Build Coastguard Worker# 193*5e7646d2SAndroid Build Coastguard Worker 194*5e7646d2SAndroid Build Coastguard Workerexit 0 195