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