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