diff options
author | jlam <jlam@pkgsrc.org> | 2003-01-23 23:05:10 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2003-01-23 23:05:10 +0000 |
commit | a56ea4178f82faa3f1a92f223776838f885885e9 (patch) | |
tree | ee3cdd008eb502421de20ebe48dbf79d225dff22 /print/cups | |
parent | 3d2a7e969cfcd692ff7e76c2efe771aea1a5b1fa (diff) | |
download | pkgsrc-a56ea4178f82faa3f1a92f223776838f885885e9.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/cups')
-rw-r--r-- | print/cups/Makefile | 3 | ||||
-rw-r--r-- | print/cups/files/cupsd.sh | 51 |
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 |