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