#!/bin/sh
#
# Re-enable all stopped print queues
# Based on http://linuxgazette.net/147/misc/lg/2_cent_tip__automatically_reenabling_cups_printer_queues.html

# Make sure lpstat, logger and cupsenable is in the PATH
PATH=/usr/bin:/usr/sbin:$PATH

log() {
    logger -t cups-queue-autoreenable "$@"
}

DISABLED=$(lpstat -t 2>/dev/null | awk '/disabled/ { print $2; }')
for PRINTER in $DISABLED ; do
    if cupsenable -h localhost $PRINTER ; then
	log "Printer queue $PRINTER was stopped, it has been enabled"
    else
	log "Printer queue $PRINTER is stopped, not able to enable it"
    fi
done
