[Pkg-cups-devel] r218 - in cupsys/branches/cups-1.2-ubuntu/debian:
local
Martin Pitt
mpitt at costa.debian.org
Tue May 9 14:52:44 UTC 2006
Author: mpitt
Date: Tue May 9 14:52:43 2006
New Revision: 218
Added:
cupsys/branches/cups-1.2-ubuntu/debian/local/enable_sharing
cupsys/branches/cups-1.2-ubuntu/debian/local/sharing_status
Modified:
cupsys/branches/cups-1.2-ubuntu/debian/changelog
cupsys/branches/cups-1.2-ubuntu/debian/rules
Log:
* Add debian/local/{sharing_status,enable_sharing}: Scripts to
control printer sharing over the CUPS browsing protocol. Thanks to Ante
Karamatić for contributing these!
Modified: cupsys/branches/cups-1.2-ubuntu/debian/changelog
==============================================================================
--- cupsys/branches/cups-1.2-ubuntu/debian/changelog (original)
+++ cupsys/branches/cups-1.2-ubuntu/debian/changelog Tue May 9 14:52:43 2006
@@ -5,8 +5,11 @@
* debian/cupsys.postinst: Fix ownership of files in /var/cache/cups/ so that
they are writable by non-root cupsd. Earlier dapper versions got the
ownership wrong, so fix this for intra-dapper upgrades. Closes: LP#40795
+ * Add debian/local/{sharing_status,enable_sharing}: Scripts to
+ control printer sharing over the CUPS browsing protocol. Thanks to Ante
+ Karamatić for contributing these!
- -- Martin Pitt <martin.pitt at ubuntu.com> Tue, 9 May 2006 16:03:10 +0200
+ -- Martin Pitt <martin.pitt at ubuntu.com> Tue, 9 May 2006 16:33:19 +0200
cupsys (1.1.99.rc3-0ubuntu2) dapper; urgency=low
Added: cupsys/branches/cups-1.2-ubuntu/debian/local/enable_sharing
==============================================================================
--- (empty file)
+++ cupsys/branches/cups-1.2-ubuntu/debian/local/enable_sharing Tue May 9 14:52:43 2006
@@ -0,0 +1,68 @@
+#!/bin/sh -e
+
+# Author: Martin Pitt <martin.pitt at ubuntu.com>
+# (C) 2005 Canonical Ltd.
+#
+# Configure CUPS IPP network browsing; this is only possible if
+# cupsd-browsing.conf is included by cupsd.conf and "Browsing" is present in
+# cupsd-browsing.conf (i. e. browsing_status returns 0 or 1). If the setting
+# changed, CUPS will be restarted.
+#
+# Argument:
+# 0: disable browsing
+# 1: enabled browsing
+# Return 0 on success, or 1 on failure (prints error to stderr)
+
+CONF=/etc/cups/cups.d/browse.conf
+STATUS_SCRIPT=/usr/share/cups/sharing_status
+PORTSCONF=/etc/cups/cups.d/ports.conf
+
+[ -x $STATUS_SCRIPT ] || {
+ echo "Error: cannot execute $STATUS_SCRIPT" >&2
+ exit 1
+}
+
+set +e
+$STATUS_SCRIPT
+STATUS=$?
+set -e
+
+case "$1" in
+ 0)
+ NEWVAL=Off
+ ;;
+ 1)
+ NEWVAL=On
+ ;;
+ *)
+ echo "Invalid argument (must be 0 or 1)" >&2
+ exit 1
+ ;;
+esac
+
+[ $STATUS = 0 -o $STATUS = 1 ] || {
+ echo "Error: cannot modify custom configuration" >&2
+ exit 1
+}
+
+# nothing to do?
+[ $1 != $STATUS ] || exit 0
+
+
+if [ $1 = 0 ]; then
+ sed -ri "s/^([[:space:]]*Listen[[:space:]]+)(631)([[:space:]]*(#.*)?)\$/\\1localhost:631\\3/i" $PORTSCONF
+else
+ sed -ri "s/^([[:space:]]*Listen[[:space:]]+)(localhost:631)([[:space:]]*(#.*)?)\$/\\1631\\3/i" $PORTSCONF
+ sed -ri "s/^([[:space:]]*Browsing[[:space:]]+)(No|Off|Yes|On)([[:space:]]*(#.*)?)\$/\\1$NEWVAL\\3/i" $CONF
+fi
+
+
+# restart CUPS
+# Automatically added by dh_installinit
+if [ -x "/etc/init.d/cupsys" ]; then
+ if [ -x /usr/sbin/invoke-rc.d ]; then
+ invoke-rc.d cupsys restart || exit 0
+ else
+ /etc/init.d/cupsys restart || exit 0
+ fi
+fi
Added: cupsys/branches/cups-1.2-ubuntu/debian/local/sharing_status
==============================================================================
--- (empty file)
+++ cupsys/branches/cups-1.2-ubuntu/debian/local/sharing_status Tue May 9 14:52:43 2006
@@ -0,0 +1,34 @@
+#!/bin/sh -e
+
+# Author: Martin Pitt <martin.pitt at ubuntu.com>
+# (C) 2005 Canonical Ltd.
+#
+# Get the status of IPP network browsing through exit code:
+#
+# 0: browsing is disabled (default configuration)
+# 1: browsing is enabled for LAN
+# 2: the configuration was adapted manually; in this case enable_browsing cannot
+# be used
+
+MAINCONF=/etc/cups/cupsd.conf
+BROWSECONF=/etc/cups/cups.d/browse.conf
+PORTSCONF=/etc/cups/cups.d/ports.conf
+
+[ -f $MAINCONF -a -f $BROWSECONF ] || exit 2
+
+# if BROWSECONF & PORTSCONF are not included -> custom
+egrep -qi "^[[:space:]]*Include[[:space:]]+($BROWSECONF|$(basename $BROWSECONF))[[:space:]]*(#.*)?\$" $MAINCONF || exit 2
+egrep -qi "^[[:space:]]*Include[[:space:]]+($PORTSCONF|$(basename $PORTSCONF))[[:space:]]*(#.*)?\$" $MAINCONF || exit 2
+
+if egrep -qi '^[[:space:]]*Browsing[[:space:]]+(No|Off)[[:space:]]*(#.*)?$' $BROWSECONF; then
+ exit 0
+fi
+
+if egrep -qi '^[[:space:]]*Browsing[[:space:]]+(Yes|On)[[:space:]]*(#.*)?$' $BROWSECONF; then
+ if egrep -qi '^[[:space:]]*Listen[[:space:]]+(631)[[:space:]]*(#.*)?$' $PORTSCONF; then
+ exit 1
+ else
+ exit 0
+ fi
+fi
+exit 2
Modified: cupsys/branches/cups-1.2-ubuntu/debian/rules
==============================================================================
--- cupsys/branches/cups-1.2-ubuntu/debian/rules (original)
+++ cupsys/branches/cups-1.2-ubuntu/debian/rules Tue May 9 14:52:43 2006
@@ -56,7 +56,7 @@
#(cd $(DEB_DESTDIR)/../cupsys/usr/share/man && mv man1/backend.1 man1/cups-backend.1 && mv man1/filter.1 man1/cups-filter.1)
(install -m 755 -o root -g root $(DEB_DESTDIR)/../pdftops $(DEB_DESTDIR)/../cupsys/usr/lib/cups/filter/)
install -o root -g root -m 644 debian/cupsys.default debian/cupsys/etc/default/cupsys
- install -m 755 debian/local/browsing_status debian/local/enable_browsing $(DEB_DESTDIR)/../cupsys/usr/share/cups
+ install -m 755 debian/local/browsing_status debian/local/enable_browsing debian/local/sharing_status debian/local/enable_sharing $(DEB_DESTDIR)/../cupsys/usr/share/cups
# Install PPDs into /usr/share/ppd/cups-included/<Manufacturer>, see
# http://wiki.debian.org/PpdFileStructureSpecification
More information about the Pkg-cups-devel
mailing list