3 # This script is an input filter for printcap printing on a unix machine. It
4 # uses the smbclient program to print the file to the specified smb-based
6 # For example you could have a printcap entry like this
8 # smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
10 # which would create a unix printer called "smb" that will print via this
11 # script. You will need to create the spool directory /usr/spool/smb with
12 # appropriate permissions and ownerships for your system.
14 # Set these to the server and service you wish to print to
15 # In this example I have a WfWg PC called "lapland" that has a printer
16 # exported called "printer" with no password.
19 # Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
20 # so that the server, service, and password can be read from
21 # a /usr/var/spool/lpd/PRINTNAME/.config file.
23 # Script further modified by Richard Sharpe to fix some things.
24 # Get rid of the -x on the first line, and add parameters
26 # -t now causes translate to be used when sending files
28 # Further modifications by Alfred Perlstein to fix some problems and
29 # improve the quality of the code (3-Dec-2001).
31 # More hacking by Richard Sharpe to improve portability. 9-Dec-2001.
33 # In order for this to work the /etc/printcap entry must include an
34 # accounting file (af=...):
37 # :cm=CD IBM Colorjet on 6th:\
38 # :sd=/var/spool/lpd/cdcolour:\
39 # :af=/var/spool/lpd/cdcolour/acct:\
40 # :if=/usr/local/etc/smbprint:\
44 # The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
46 # service=PR_SHARENAME
54 #smbclient=/usr/pkg/bin/smbclient
55 # Assume that smbclient will be in the same place as smbprint
57 smbclient
="`dirname $0`/smbclient"
60 # The last parameter to the filter is the accounting file name.
61 # Extract the directory name from the file name.
62 # Concat this with /.config to get the config file.
66 spool_dir
=`dirname $acct_file`
67 config_file
=$spool_dir/.config
69 # Should read the following variables set in the config file:
77 # debugfile (optional)
80 if [ "x$password" = "x" ] ; then
84 if [ "x$username" == "x" ] ; then
88 while test $# -gt 0; do
94 *) # Bad Parameters, ignore them ...
101 if [ $TRANS -eq 1 ]; then
102 command="translate;$command";
105 debugfile
="/tmp/smb-print.log"
106 if [ "x$debug" = "x" ] ; then
107 debugfile
=/dev
/null debugargs
=
109 if [ $debug -eq 0 ] ; then
110 debugfile
=/dev
/null debugargs
=
112 set -x; exec >>$debugfile 2>&1
113 debugargs
="$debugfile."
114 #[ "x$debugsmb" == "x" ] || debugargs="$debugargs -d $debugsmb"
118 if [ "x$smbconf" != "x" ]; then
120 smbconf
="-s $smbconf"
124 if [ "x$IP" != "x" ]; then
130 if [ "x$debugargs" != "x" ]; then
132 debugargs
="-l $debugargs"
137 "\\\\$server\\$service" \