]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | #!/bin/sh |
2 | # | |
4d301e69 | 3 | # "$Id$" |
ef416fc2 | 4 | # |
5a1d7a17 | 5 | # Startup/shutdown script for CUPS. |
ef416fc2 | 6 | # |
5a1d7a17 MS |
7 | # Copyright 2007-2013 by Apple Inc. |
8 | # Copyright 1997-2007 by Easy Software Products, all rights reserved. | |
ef416fc2 | 9 | # |
5a1d7a17 MS |
10 | # These coded instructions, statements, and computer programs are the |
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 | |
5a1d7a17 | 118 | # since some operating systems don't provide a standard path on boot-up... |
f7deaa1a | 119 | # |
120 | ||
7594b224 | 121 | if test "x$PATH" = x; then |
f7deaa1a | 122 | PATH="/bin:/usr/bin:/sbin:/usr/sbin" |
123 | else | |
124 | PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH" | |
125 | fi | |
126 | ||
127 | export PATH | |
128 | ||
ef416fc2 | 129 | # |
130 | # See if the CUPS server (cupsd) is running... | |
131 | # | |
132 | ||
133 | case "`uname`" in | |
3dd9c340 | 134 | SunOS*) |
ef416fc2 | 135 | pid=`ps -e | nawk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'` |
136 | ;; | |
ef416fc2 | 137 | Linux* | *BSD* | Darwin*) |
138 | pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'` | |
139 | ;; | |
140 | *) | |
141 | pid="" | |
142 | ;; | |
143 | esac | |
144 | ||
145 | # | |
146 | # Start or stop the CUPS server based upon the first argument to the script. | |
147 | # | |
148 | ||
149 | case $1 in | |
150 | start | restart | reload) | |
151 | if $IS_ON cups; then | |
85dda01c MS |
152 | if test -x /sbin/portrelease; then |
153 | /sbin/portrelease cups | |
154 | fi | |
155 | ||
ef416fc2 | 156 | if test "$pid" != ""; then |
157 | kill -HUP $pid | |
158 | else | |
159 | prefix=@prefix@ | |
160 | exec_prefix=@exec_prefix@ | |
161 | @sbindir@/cupsd | |
162 | if test $? != 0; then | |
163 | $ECHO_FAIL | |
164 | $ECHO "cups: unable to $1 scheduler." | |
165 | exit 1 | |
166 | fi | |
167 | fi | |
168 | $ECHO_OK | |
169 | $ECHO "cups: ${1}ed scheduler." | |
170 | fi | |
171 | ;; | |
172 | ||
173 | stop) | |
174 | if test "$pid" != ""; then | |
175 | kill $pid | |
176 | $ECHO_OK | |
177 | $ECHO "cups: stopped scheduler." | |
178 | fi | |
179 | ;; | |
180 | ||
181 | status) | |
182 | if test "$pid" != ""; then | |
183 | echo "cups: scheduler is running." | |
184 | else | |
185 | echo "cups: scheduler is not running." | |
186 | fi | |
187 | ;; | |
188 | ||
189 | *) | |
190 | echo "Usage: cups {reload|restart|start|status|stop}" | |
191 | exit 1 | |
192 | ;; | |
193 | esac | |
194 | ||
195 | # | |
196 | # Exit with no errors. | |
197 | # | |
198 | ||
199 | exit 0 | |
200 | ||
201 | ||
202 | # | |
4d301e69 | 203 | # End of "$Id$". |
ef416fc2 | 204 | # |