Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Sep 2010 18:41:16 -0400 (EDT)
From:      Garrett Wollman <wollman@hergotha.csail.mit.edu>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/150891: [cups-base] slightly more worked-out example devd scripts
Message-ID:  <201009232241.o8NMfGfc075522@hergotha.csail.mit.edu>
Resent-Message-ID: <201009232250.o8NMo15H040727@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         150891
>Category:       ports
>Synopsis:       [cups-base] slightly more worked-out example devd scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 23 22:50:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Garrett Wollman
>Release:        FreeBSD 8.1-RELEASE amd64
>Organization:
FreeBSD project
>Environment:
System: FreeBSD hergotha.csail.mit.edu 8.1-RELEASE FreeBSD 8.1-RELEASE #0 r212140M: Sat Sep 4 00:16:21 EDT 2010 wollman@hergotha.csail.mit.edu:/usr/obj/usr/src/sys/HERGOTHA amd64

>Description:

cups-base installs a devd configuration fragment that handles one
aspect (permissions) of ulpt devices' transitory existence.  I built
something a little bit more complicated that also pauses and unpauses
the relevant print queues when printers arrive and depart.  I don't
know if anyone else will find this useful -- I didn't even notice the
example script until after I had built mine.  (Is it possible that
cupsd will keep retrying until the printer reappears?  It wasn't at
all obvious to me.)

>How-To-Repeat:


>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	ulpt.awk
#	ulpt.conf
#	ulpt.script
#
echo x - ulpt.awk
sed 's/^X//' >ulpt.awk << '0ad6437134085951c9cf3a730210b10c'
X/^<(Default)?Printer[[:space:]]/ { 
X	if (match($0, /[^[:space:]>]+>/)) {
X		PRINTER=substr($0, RSTART, RLENGTH - 1);
X	}
X}
X/^<\/(Default)?Printer/ {
X	PRINTER=""
X}
Xmatch($0, "DeviceURI[[:space:]]+usb:/dev/" ENVIRON["DEVICENAME"] "\$") {
X	print PRINTER
X}
0ad6437134085951c9cf3a730210b10c
echo x - ulpt.conf
sed 's/^X//' >ulpt.conf << '5f167b5e895f429179122d02fa2a01a2'
X# Tell cups to pause and unpause the printer when it arrives and departs.
Xattach 10 {
X	device-name "ulpt[0-9]";
X	action "/etc/devd/ulpt.script enable $device-name";
X};
X
Xdetach 10 {
X	device-name "ulpt[0-9]";
X	action "/etc/devd/ulpt.script disable $device-name";
X};
5f167b5e895f429179122d02fa2a01a2
echo x - ulpt.script
sed 's/^X//' >ulpt.script << '0f8c62a030511cba959e182fedf10721'
X#!/bin/sh
X
Xusage() {
X	echo "$0: usage:" >&2
X	echo "$0 [enable|disable] devicename" >&2
X	exit 1
X}
X
Xif [ -z "$2" ]; then
X	usage
Xfi
X
Xprinter="$(DEVICENAME="$2" awk -f /etc/devd/ulpt.awk /usr/local/etc/cups/printers.conf)"
X
Xif [ -z "$printer" ]; then
X	# nothing to do
X	exit 0
Xfi
X
Xcase "$1" in
Xenable)	chown cups:cups "/dev/$2"
X	/usr/local/sbin/cupsenable "$printer"
X	;;
Xdisable)
X	/usr/local/sbin/cupsdisable "$printer"
X	;;
X*)
X	usage
X	;;
Xesac
Xexit 0
0f8c62a030511cba959e182fedf10721
exit
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009232241.o8NMfGfc075522>