From d3434b482c13acb4075c89424ab474d3539b680b Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 5 Mar 2024 14:44:10 +0100 Subject: [PATCH] Added handling of ppd files --- printer.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/printer.sh b/printer.sh index 6390e4a..d1951e0 100644 --- a/printer.sh +++ b/printer.sh @@ -87,9 +87,14 @@ function printer_duplicate { sed -i 's/^StateMessage .\+$//' ${TEMP_CONF_FILE} sed -i 's/^Reason .\+$//' ${TEMP_CONF_FILE} - # Add new configuration to CUPS + # Add new configuration to CUPS and copy PPD file if exists systemctl stop cups cat ${TEMP_CONF_FILE} >> /etc/cups/printers.conf + if [ -f "/etc/cups/ppd/${PRINTER}.ppd" ]; then + cp "/etc/cups/ppd/${PRINTER}.ppd" "/etc/cups/ppd/${PRINTER}_duplicate.ppd" + else + echo "Info: No printer definition file copied" + fi systemctl start cups rm "${TEMP_CONF_FILE}" @@ -143,6 +148,11 @@ function printer_rename { # Stop CUPS, rename, restart CUPS systemctl stop cups sed -i 's/$//' /etc/cups/printers.conf + if [ -f "/etc/cups/ppd/${PRINTER}.ppd" ]; then + mv "/etc/cups/ppd/${PRINTER}.ppd" "/etc/cups/ppd/${NEW_NAME}.ppd" + else + echo "Info: No printer definition file moved" + fi systemctl start cups echo "OK"