#!/bin/sh set -e case "$1" in install|upgrade) if dpkg --compare-versions "$2" le "1.6.1" && [ -e /etc/cups/cupsd.conf ]; then # Move cupsd.conf away as it becomes a non-conffile mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.conffile-bak fi # If file doesn't exist, has two conflicting stanzas or has a "listen-to-all" while cupsd.conf says it should 'listen-to-localhost' if [ ! -f /etc/cups/cupsd-systemd-listen.conf ] || \ ( grep -q '^ListenStream=0.0.0.0:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null && \ grep -q '^ListenStream=127.0.0.1:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null ) || ( grep -q '^ListenStream=0.0.0.0:' /etc/cups/cupsd-systemd-listen.conf 2>/dev/null && \ grep -q '^\s*Listen localhost:' /etc/cups/cupsd.conf 2>/dev/null );\ then mkdir -p /etc/cups cat >/etc/cups/cupsd-systemd-listen.conf </dev/null; then localport=`grep '^\s*Port' /etc/cups/cupsd.conf | head -n1 | sed -e 's/.*Port \([[:digit:]]*\)$/\1/'` cat >>/etc/cups/cupsd-systemd-listen.conf </dev/null; then localport=`grep '^\s*Listen localhost:' /etc/cups/cupsd.conf | head -n1 | sed -e 's/.*localhost\:\([[:digit:]]*\)$/\1/'` cat >>/etc/cups/cupsd-systemd-listen.conf <>/etc/cups/cupsd-systemd-listen.conf <