Changed valid printer name characters
This commit is contained in:
14
printer.sh
14
printer.sh
@@ -44,7 +44,7 @@ function printer_duplicate {
|
||||
|
||||
PRINTER=${1}
|
||||
echo "Duplicating printer '${PRINTER}'..."
|
||||
|
||||
|
||||
if [ "${PRINTER}" = "" ]; then
|
||||
echo "No printer specified!"
|
||||
exit 1
|
||||
@@ -106,7 +106,7 @@ function printer_rename {
|
||||
PRINTER=${1}
|
||||
NEW_NAME=${2}
|
||||
echo "Renaming printer '${PRINTER}' to '${NEW_NAME}'..."
|
||||
|
||||
|
||||
if [ "${PRINTER}" = "" ]; then
|
||||
echo "No printer specified!"
|
||||
exit 1
|
||||
@@ -118,9 +118,9 @@ function printer_rename {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -qE '^[a-zA-Z0-9_]+$' <<< "${NEW_NAME}"; then
|
||||
if grep -qE '[ \/'\''"?#]' <<< "${NEW_NAME}"; then
|
||||
echo "Invalid characters in new name '${NEW_NAME}'!"
|
||||
echo "Valid characters are: A-Z a-z 0-9 _"
|
||||
echo "Valid characters are anything except \" ' \\ / ? # and spaces"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -139,7 +139,7 @@ function printer_rename {
|
||||
fi
|
||||
|
||||
cp /etc/cups/printers.conf /etc/cups/printers.conf.ren_bak
|
||||
|
||||
|
||||
# Stop CUPS, rename, restart CUPS
|
||||
systemctl stop cups
|
||||
sed -i 's/<Printer '${PRINTER}'>$/<Printer '${NEW_NAME}'>/' /etc/cups/printers.conf
|
||||
@@ -156,7 +156,7 @@ function printer_rename {
|
||||
function printer_clear_queue {
|
||||
PRINTER=${1}
|
||||
echo "Clearing printing queue of '${PRINTER}'..."
|
||||
|
||||
|
||||
if [ "${PRINTER}" = "" ]; then
|
||||
echo "No printer specified!"
|
||||
exit 1
|
||||
@@ -213,4 +213,4 @@ case "$1" in
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user