Sign in before continuing.
Changes
Page history
torstenn created page: dotfiles
authored
Apr 25, 2017
by
Torsten Nielsen
Show whitespace changes
Inline
Side-by-side
print-via-samba.md
View page @
7909846f
...
...
@@ -108,3 +108,74 @@ There are other ways to create printers and link a PPD file:
*
GUI-interface
See
[
More about CUPS
](
more
about cups)
```
and added this smbc script to /usr/lib/cups/backend/smbc
-------------------------- smbc --------------------------------
#!/bin/sh
if [ "$1" = "" ]; then
# list supported output types
echo 'network smbc "Unknown" "Windows Printer using smbclient"'
exit 0
fi
job="$1"
account="$2"
title="$3"
numcopies="$4"
options="$5"
filename="$6"
username=`grep /etc/samba/printing.auth -e username | awk '{split($0,a,"
"); print a[3] }'`
if [ "$filename" = "" ]; then
filename=-
fi
# strip protocol from printer
printer=`echo "${DEVICE_URI}" | sed 's/^.*://'`
#username=`echo "${DEVICE_URI}" | sed 's/^.*://'`
logger " logging for smbc" $job "|" $account"|" $title"|" $numcopies"|"
$options"|" $filename"|" $printer
# and print using smbclient
echo "NOTICE: smbclient -N -A /etc/samba/printing.auth -c \"print
${filename}\" \"${printer}\"" 1>&2
errtxt=`smbclient -N -A /etc/samba/printing.auth -U ${username} -c
"print ${filename}" "${printer}" 2>&1`
ret=${?}
#logger 'smbclient -N -A /etc/samba/printing.auth -U ${username} -c
"print ${filename}" "${printer}"'
#logger $errtxt
# Handle errors
# see backend(7) for error codes
# log message
if [ "$ret" = "0" ]; then
echo "$errtxt" | sed 's/^/NOTICE: /' 1>&2
else
echo "$errtxt" | sed 's/^/ERROR: /' 1>&2
fi
# "NT_STATUS_LOGON_FAILURE" -> CUPS_BACKEND_AUTH_REQUIRED
echo "$errtxt" | grep -i 'LOGON_FAILURE' >/dev/null && return 2
# "Unable to open credentials file!" -> CUPS_BACKEND_AUTH_REQUIRED
echo "$errtxt" | grep -i 'credentials' >/dev/null && return 2
# "NT_STATUS_BAD_NETWORK_NAME" -> CUPS_BACKEND_STOP
echo "$errtxt" | grep -i 'BAD_NETWORK_NAME' >/dev/null && return 4
# something went wrong, don't know what -> CUPS_BACKEND_FAILED
[ "$ret" != "0" ] && return 1
# success! -> CUPS_BACKEND_OK
return 0
-----------------------
```