Set *DefaultBRColorMode: None in the vendor PPD so every job sends <</UseCIEColor false>>: Brother's Normal/Vivid modes enable the printer's own CIE conversion, which washed the colours out. Add six APPrinterPreset entries mapping print-color-mode and print-quality from driverless (AirPrint/IPP) clients onto the Brother device options; they use the notation CUPS generates itself (Apple metadata as 'key value' pairs, PPD options as '*Name Value'), because key=value strings are silently discarded. print-quality is 3/4/5. Add the PRINTER_OPTIONS env var: whitespace-separated key=value pairs applied as queue defaults on every start via lpadmin -o, validated against the queue's PPD, with warnings instead of a failed startup. Document all of it in the README. The VividNoCIE candidate was dropped after test prints showed no difference from None. Archive the OpenSpec change and sync the printserver/cups spec with the two new requirements.
This commit is contained in:
1 parent
75b68fe438
commit
30670de93b
9 files changed
+319
-33
No files matched your search
@@ -18,6 +18,9 @@
|
||||
# PRINTER_NAME CUPS queue name and advertised (DNS-SD) name.
|
||||
# PRINTER_DESCRIPTION CUPS Description (lpadmin -D) shown in the web UI.
|
||||
# PPD_FILE PPD used for the queue.
|
||||
# PRINTER_OPTIONS Space-separated PPD option assignments (key=value)
|
||||
# applied as queue defaults on every start, e.g.
|
||||
# "BRColorMode=Vivid TonerSaveMode=False".
|
||||
# CERT_EXTRA_NAMES Comma-separated extra DNS names / IP addresses to put
|
||||
# into the generated IPPS certificate (server SANs).
|
||||
# CERT_DAYS Validity of the generated certificate (default 3650).
|
||||
@@ -29,6 +32,7 @@ PRINTER_URI="${PRINTER_URI:-}"
|
||||
PRINTER_PROTOCOL="${PRINTER_PROTOCOL:-socket}"
|
||||
PRINTER_DESCRIPTION="${PRINTER_DESCRIPTION:-}"
|
||||
PPD_FILE="${PPD_FILE:-/usr/share/cups/model/BR4150_2.PPD}"
|
||||
PRINTER_OPTIONS="${PRINTER_OPTIONS:-}"
|
||||
|
||||
LOG_PREFIX="[entrypoint]"
|
||||
log() { echo "${LOG_PREFIX} $*"; }
|
||||
@@ -331,6 +335,50 @@ if lpstat -p "${PRINTER_NAME}" >/dev/null 2>&1; then
|
||||
log "queue ${PRINTER_NAME} is shared and set as default"
|
||||
fi
|
||||
|
||||
# Apply optional queue defaults from PRINTER_OPTIONS (see README). Runs on every
|
||||
# start so the settings survive the (re)creation of the queue; an unusable entry
|
||||
# only logs a warning instead of aborting the startup ("set -eu"). Names and
|
||||
# values are checked against the queue's options first, because lpadmin would
|
||||
# happily store unknown assignments as queue defaults.
|
||||
apply_printer_options() {
|
||||
[ -n "${PRINTER_OPTIONS}" ] || return 0
|
||||
if ! lpstat -p "${PRINTER_NAME}" >/dev/null 2>&1; then
|
||||
log "warning: queue ${PRINTER_NAME} does not exist; skipping PRINTER_OPTIONS"
|
||||
return 0
|
||||
fi
|
||||
ppd_options="$(lpoptions -p "${PRINTER_NAME}" -l 2>/dev/null || true)"
|
||||
for opt in ${PRINTER_OPTIONS}; do
|
||||
case "${opt}" in
|
||||
?*=*) ;;
|
||||
*)
|
||||
log "warning: ignoring malformed PRINTER_OPTIONS entry '${opt}' (expected key=value)"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
name="${opt%%=*}"
|
||||
value="${opt#*=}"
|
||||
line="$(printf '%s\n' "${ppd_options}" | grep "^${name}/")" || {
|
||||
log "warning: PPD has no option '${name}'; ignoring (names/values: 'lpoptions -p ${PRINTER_NAME} -l')"
|
||||
continue
|
||||
}
|
||||
# Option lines look like "Name/Text: value1 value2 ..." ('*' = default).
|
||||
values="$(printf '%s\n' "${line#*: }" | tr ' ' '\n' | sed 's/^\*//')"
|
||||
if ! printf '%s\n' "${values}" | grep -qxF "${value}" \
|
||||
&& ! { case "${value}" in Custom.*)
|
||||
printf '%s\n' "${values}" | grep -q 'Custom\.'
|
||||
;; *) false ;; esac; }; then
|
||||
log "warning: PPD option '${name}' has no value '${value}'; ignoring"
|
||||
continue
|
||||
fi
|
||||
if lpadmin -p "${PRINTER_NAME}" -o "${opt}" >/dev/null 2>&1; then
|
||||
log "queue default ${opt} applied"
|
||||
else
|
||||
log "warning: lpadmin -o ${opt} failed; ignoring"
|
||||
fi
|
||||
done
|
||||
}
|
||||
apply_printer_options
|
||||
|
||||
# --- Verify CUPS is reachable on the network --------------------------------
|
||||
# cupsd also runs with nothing but its domain socket, e.g. when it cannot bind
|
||||
# the privileged port 631 (rootless Podman with host networking). It then still
|
||||
|
||||
Reference in new issue
Block a user