]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/cups.sh.in
Merge changes from CUPS 1.6svn-r9968.
[thirdparty/cups.git] / scheduler / cups.sh.in
CommitLineData
ef416fc2 1#!/bin/sh
2#
4d301e69 3# "$Id$"
ef416fc2 4#
321d8d57 5# Startup/shutdown script for CUPS.
ef416fc2 6#
321d8d57 7# Copyright 2007-2011 by Apple Inc.
f7deaa1a 8# Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 9#
10# These coded instructions, statements, and computer programs are the
bc44d920 11# property of Apple Inc. and are protected by Federal copyright
12# law. Distribution and use rights are outlined in the file "LICENSE.txt"
13# which should have been included with this file. If this file is
14# file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 15#
16
17#### OS-Dependent Information
18
19#
20# Linux chkconfig stuff:
21#
22# chkconfig: 235 99 00
321d8d57 23# description: Startup/shutdown script for CUPS.
ef416fc2 24#
25
26#
27# NetBSD 1.5+ rcorder script lines. The format of the following two
28# lines is very strict -- please don't add additional spaces!
29#
30# PROVIDE: cups
31# REQUIRE: DAEMON
32#
33
34
35#### OS-Dependent Configuration
36
37case "`uname`" in
38 IRIX*)
39 IS_ON=/sbin/chkconfig
40
41 if $IS_ON verbose; then
42 ECHO=echo
43 else
44 ECHO=:
45 fi
46 ECHO_OK=:
47 ECHO_ERROR=:
48 ;;
49
50 *BSD*)
51 IS_ON=:
52 ECHO=echo
53 ECHO_OK=:
54 ECHO_ERROR=:
55 ;;
56
57 Darwin*)
58 . /etc/rc.common
59
60 if test "${CUPS:=-YES-}" = "-NO-"; then
61 exit 0
62 fi
63
64 IS_ON=:
65 ECHO=ConsoleMessage
66 ECHO_OK=:
67 ECHO_ERROR=:
68 ;;
69
70 Linux*)
71 IS_ON=/bin/true
72 if test -f /etc/init.d/functions; then
73 . /etc/init.d/functions
74 ECHO=echo
75 ECHO_OK="echo_success"
76 ECHO_ERROR="echo_failure"
77 else
78 ECHO=echo
79 ECHO_OK=:
80 ECHO_ERROR=:
81 fi
82 ;;
83
84 *)
85 IS_ON=/bin/true
86 ECHO=echo
87 ECHO_OK=:
88 ECHO_ERROR=:
89 ;;
90esac
91
92#### OS-Independent Stuff
93
94#
bd7854cb 95# Set the timezone, if possible... This allows the scheduler and
96# all child processes to know the local timezone when reporting
97# dates and times to the user. If no timezone information is
98# found, then Greenwich Mean Time (GMT) will probably be used.
ef416fc2 99#
100
101for file in /etc/TIMEZONE /etc/rc.config /etc/sysconfig/clock; do
102 if test -f $file; then
103 . $file
104 fi
105done
106
107if test "x$ZONE" != x; then
108 TZ="$ZONE"
109fi
110
111if test "x$TIMEZONE" != x; then
112 TZ="$TIMEZONE"
113fi
114
115if test "x$TZ" != x; then
116 export TZ
117fi
118
bd7854cb 119#
120# Don't use TMPDIR environment variable from init script, as that can
121# cause cupsd to set TempDir to a user's temporary directory instead
122# of the default...
123#
124
125unset TMPDIR
126
127
f7deaa1a 128#
129# Make sure we have the standard program directories in the path
130# since some operating systems (this means YOU HP-UX!) don't
131# provide a standard path on boot-up...
132#
133
7594b224 134if test "x$PATH" = x; then
f7deaa1a 135 PATH="/bin:/usr/bin:/sbin:/usr/sbin"
136else
137 PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
138fi
139
140export PATH
141
ef416fc2 142#
143# See if the CUPS server (cupsd) is running...
144#
145
146case "`uname`" in
147 HP-UX* | AIX* | SINIX*)
148 pid=`ps -e | awk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'`
149 ;;
150 IRIX* | SunOS*)
151 pid=`ps -e | nawk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'`
152 ;;
153 UnixWare*)
154 pid=`ps -e | awk '{if (match($6, ".*/cupsd$") || $6 == "cupsd") print $1}'`
155 . /etc/TIMEZONE
156 ;;
157 OSF1*)
158 pid=`ps -e | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
159 ;;
160 Linux* | *BSD* | Darwin*)
161 pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
162 ;;
163 *)
164 pid=""
165 ;;
166esac
167
168#
169# Start or stop the CUPS server based upon the first argument to the script.
170#
171
172case $1 in
173 start | restart | reload)
174 if $IS_ON cups; then
85dda01c
MS
175 if test -x /sbin/portrelease; then
176 /sbin/portrelease cups
177 fi
178
ef416fc2 179 if test "$pid" != ""; then
180 kill -HUP $pid
181 else
182 prefix=@prefix@
183 exec_prefix=@exec_prefix@
184 @sbindir@/cupsd
185 if test $? != 0; then
186 $ECHO_FAIL
187 $ECHO "cups: unable to $1 scheduler."
188 exit 1
189 fi
190 fi
191 $ECHO_OK
192 $ECHO "cups: ${1}ed scheduler."
193 fi
194 ;;
195
196 stop)
197 if test "$pid" != ""; then
198 kill $pid
199 $ECHO_OK
200 $ECHO "cups: stopped scheduler."
201 fi
202 ;;
203
204 status)
205 if test "$pid" != ""; then
206 echo "cups: scheduler is running."
207 else
208 echo "cups: scheduler is not running."
209 fi
210 ;;
211
f7deaa1a 212 start_msg)
213 # HP-UX non-standard...
214 echo "Starting CUPS Server"
215 ;;
216
217 stop_msg)
218 # HP-UX non-standard...
219 echo "Starting CUPS Server"
220 ;;
221
ef416fc2 222 *)
223 echo "Usage: cups {reload|restart|start|status|stop}"
224 exit 1
225 ;;
226esac
227
228#
229# Exit with no errors.
230#
231
232exit 0
233
234
235#
4d301e69 236# End of "$Id$".
ef416fc2 237#