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