summaryrefslogtreecommitdiff
path: root/print
diff options
context:
space:
mode:
authorjlam <jlam>2003-01-23 23:05:10 +0000
committerjlam <jlam>2003-01-23 23:05:10 +0000
commit603207acf180857a4bad1a7d0bddb0352e1cb0ae (patch)
treeee3cdd008eb502421de20ebe48dbf79d225dff22 /print
parent2609d01211a1c912ea301773d51c3212d3819524 (diff)
downloadpkgsrc-603207acf180857a4bad1a7d0bddb0352e1cb0ae.tar.gz
Create a new cupsd command "wait" that waits for cupsd to start responding
to IPP requests. It's controlled by two new variables that may be set in /etc/rc.conf: cupsd_wait=YES # set to "YES" to wait for cupsd to detect printers; # this variable is optional and defaults to "NO". cupsd_timeout=60 # set to the number of seconds we wait for cupsd # to respond before we declare it not responding; # this variable is optional and defaults to "60". The wait command may also be directly invoked as "/etc/rc.d/cupsd wait". Bump PKGREVISION of print/cups to 1.
Diffstat (limited to 'print')
-rw-r--r--print/cups/Makefile3
-rw-r--r--print/cups/files/cupsd.sh51
2 files changed, 51 insertions, 3 deletions
diff --git a/print/cups/Makefile b/print/cups/Makefile
index c5ef75bf7c6..5764848b583 100644
--- a/print/cups/Makefile
+++ b/print/cups/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.57 2003/01/10 07:46:02 cjep Exp $
+# $NetBSD: Makefile,v 1.58 2003/01/23 23:05:10 jlam Exp $
#
# The CUPS author is very good about taking back changes into the main
# CUPS distribution. The correct place to send patches or bug-fixes is:
@@ -6,6 +6,7 @@
DISTNAME= cups-${DIST_VERS}-source
PKGNAME= cups-${VERS}
+PKGREVISION= 1
BASE_VERS= 1.1.18
DIST_VERS= ${BASE_VERS}
VERS= ${DIST_VERS:S/-/./g}
diff --git a/print/cups/files/cupsd.sh b/print/cups/files/cupsd.sh
index 5b006d8f283..2ccbe3259f3 100644
--- a/print/cups/files/cupsd.sh
+++ b/print/cups/files/cupsd.sh
@@ -1,11 +1,20 @@
#!@RCD_SCRIPTS_SHELL@
#
-# $NetBSD: cupsd.sh,v 1.14 2002/10/31 23:33:12 jlam Exp $
+# $NetBSD: cupsd.sh,v 1.15 2003/01/23 23:05:11 jlam Exp $
#
# Common UNIX Printing System daemon
#
# PROVIDE: cupsd
# REQUIRE: DAEMON
+#
+# You will need to set some variables in /etc/rc.conf to start cupsd:
+#
+# cupsd=YES
+# cupsd_wait=YES # set to "YES" to wait for cupsd to detect printers;
+# # this variable is optional and defaults to "NO".
+# cupsd_timeout=60 # set to the number of seconds we wait for cupsd
+# # to respond before we declare it not responding;
+# # this variable is optional and defaults to "60".
if [ -f /etc/rc.subr ]
then
@@ -15,9 +24,47 @@ fi
name="cupsd"
rcvar=${name}
command="@PREFIX@/sbin/${name}"
+lpstat_command="@PREFIX@/bin/lpstat"
command_args="& sleep 2"
required_files="@PKG_SYSCONFDIR@/${name}.conf"
-extra_commands="reload"
+extra_commands="reload wait"
+wait_cmd="cupsd_waitcmd"
+start_postcmd="cupsd_poststart"
+
+[ -z "${cupsd_wait}" ] && cupsd_wait=NO
+[ -z "${cupsd_timeout}" ] && cupsd_timeout=60
+
+cupsd_poststart()
+{
+ if checkyesno cupsd_wait; then
+ $0 wait
+ fi
+}
+
+cupsd_waitcmd()
+{
+ if [ -x ${lpstat_command} ]; then
+ msg=
+ @ECHO@ -n "Waiting ${cupsd_timeout} seconds for ${name}: "
+ if ${lpstat_command} -r >/dev/null 2>&1; then
+ msg='responding'
+ else
+ master=$$
+ trap "msg='not responding'" ALRM
+ (sleep ${cupsd_timeout} && kill -ALRM $master) >/dev/null 2>&1 &
+ while [ -z "$msg" ]; do
+ if ${lpstat_command} -r >/dev/null 2>&1; then
+ msg='responding'
+ trap : ALRM
+ else
+ sleep 5
+ @ECHO@ -n '.'
+ fi
+ done
+ fi
+ @ECHO@ "$msg"
+ fi
+}
if [ -f /etc/rc.subr ]
then