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