#!/bin/sh set -e -u DUMMY_PRINTER_NAME=test-printer0 DRIVER_REGEXP='^.*' PDFS_PATH=/usr/share/cups/data/ LPINFO_RUN=true DRIVERS_LIST='' while getopts 'n:r:p:l:h' flag; do case "${flag}" in n) DUMMY_PRINTER_NAME="${OPTARG}" ;; r) DRIVER_REGEXP="${OPTARG}" ;; p) PDFS_PATH="${OPTARG}" ;; l) LPINFO_RUN=false; DRIVERS_LIST=${OPTARG} ;; h) echo "Usage: $0 [-n printer_name] [-r '^driver_regexp'] [-p ./pdf-path] [-l drivers_list]"; return 1;; esac done if $LPINFO_RUN; then # textonly, gen-brf, gen-ubrl and indexv[3,4] can't print PDF # pdftoijs is currently buggy !? DRIVERS_LIST=$(lpinfo -m | cut -f1 -d' ' | grep -Ev 'brf|everywhere|gen-ubrl|indexv[3,4]|pdftoijs|raw|textonly' | grep -E $DRIVER_REGEXP) fi cleanup() { # Delete it echo -n " - Interrupted (or finished), delete test printer:" rm -f ${DUMMY_PRINTER_STDERR_FILE} /usr/sbin/lpadmin -x $DUMMY_PRINTER_NAME 2>/dev/null || : echo " done." } trap cleanup EXIT INT DUMMY_PRINTER_STDERR_FILE=`mktemp` for driver in $DRIVERS_LIST; do echo "* Driver $driver" echo -n " - Create test printer:" # Create dummy printer /usr/sbin/lpadmin -p $DUMMY_PRINTER_NAME -E -m $driver -v file:///dev/null 2> $DUMMY_PRINTER_STDERR_FILE echo " done." # Tell stderr whether some unknown lines have been seen # Filter out the deprecation messages # Both messages from systemv/lpadmin.c cat "${DUMMY_PRINTER_STDERR_FILE}" | \ grep -v -E "lpadmin: (Raw queues|Printer drivers) are deprecated and will stop working in a future version of CUPS." \ || true \ 1>&2 for file in $(find $PDFS_PATH -name '*.pdf') ; do echo -n " - Print test job with $file: " # Print the default testprint to it, get request id rid=$(/usr/bin/lp -d $DUMMY_PRINTER_NAME $file | sed -e 's/^.*request id is \(.*\) (.*)$/\1/g') # Wait for the print to finish while LPSTAT=`LANG=C /usr/bin/lpstat -l` && echo $LPSTAT | grep -q "^$rid "; do # If the filter is failed; stop the waiting and give as much context as possible if echo $LPSTAT | grep -A3 "^$rid" | grep -q "Filter failed"; then echo " Filter failed, aborting!" >&2 echo "$ lpstat -l" >&2 echo "$LPSTAT" # Get job-id from request-id; assume it's ${printer_name}-${job_id} jobid=$(echo $rid | sed -e "s/^${DUMMY_PRINTER_NAME}-//g") >&2 echo "$ grep "\[Job $jobid\]" /var/log/cups/error_log" >&2 grep "\[Job $jobid\]" /var/log/cups/error_log break fi /bin/sleep 1s echo -n "." done echo " done." done # Delete it echo -n " - Delete test printer:" /usr/sbin/lpadmin -x $DUMMY_PRINTER_NAME echo " done." done
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
banners | Folder | 0755 |
|
|
braille | Folder | 0755 |
|
|
charsets | Folder | 0755 |
|
|
data | Folder | 0755 |
|
|
doc-root | Folder | 0755 |
|
|
drv | Folder | 0755 |
|
|
examples | Folder | 0755 |
|
|
ipptool | Folder | 0755 |
|
|
locale | Folder | 0755 |
|
|
mime | Folder | 0755 |
|
|
model | Folder | 0755 |
|
|
ppd-updaters | Folder | 0755 |
|
|
ppdc | Folder | 0755 |
|
|
profiles | Folder | 0755 |
|
|
templates | Folder | 0755 |
|
|
usb | Folder | 0755 |
|
|
cups-files.conf.default | File | 2.85 KB | 0644 |
|
cupsd.conf.default | File | 6.35 KB | 0644 |
|
snmp.conf.default | File | 142 B | 0644 |
|
test-drivers | File | 2.81 KB | 0755 |
|