samba/smbprint

85 lines
2.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based
# server and service.
# For example you could have a printcap entry like this
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# which would create a unix printer called "smb" that will print via this
# script. You will need to create the spool directory /usr/spool/smb with
# appropriate permissions and ownerships for your system.
# Set these to the server and service you wish to print to
# In this example I have a WfWg PC called "lapland" that has a printer
# exported called "printer" with no password.
#
# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
# so that the server, service, and password can be read from
# a /usr/var/spool/lpd/PRINTNAME/.config file.
#
# In order for this to work the /etc/printcap entry must include an
# accounting file (af=...):
#
# cdcolour:\
# :cm=CD IBM Colorjet on 6th:\
# :sd=/var/spool/lpd/cdcolour:\
# :af=/var/spool/lpd/cdcolour/acct:\
# :if=/usr/local/etc/smbprint:\
# :mx=0:\
# :lp=/dev/null:
#
# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
# share=PC_SERVER
# user="user"
# password="password"
#
# Please, do not modify the order in the file.
# Example:
# share=\\server\deskjet
# user="fred"
# password=""
#
# The last parameter to the filter is the accounting file name.
# Extract the directory name from the file name.
# Concat this with /.config to get the config file.
#
auto-import changelog data from samba-3.0.0-15.src.rpm * Thu Sep 25 2003 Jay Fenlason <fenlason@redhat.com> 3.0.0-15 - New 3.0.0 final release - merge nmbd-netbiosname and testparm patches from 3E branch - updated the -logfiles patch to work against 3.0.0 - updated the pie patch - update the VERSION file during build - use make -j if avaliable - merge the winbindd_privileged change from 3E - merge the "rm /usr/lib" patch that allows Samba to build on 64-bit platforms despite the broken Makefile * Mon Aug 18 2003 Jay Fenlason <fenlason@redhat.com> - Merge from samba-3E-branch after samba-3.0.0rc1 was released * Wed Jul 23 2003 Jay Fenlason <fenlason@redhat.com> 3.0.0-3beta3 - Merge from 3.0.0-2beta3.3E - (Correct log file names (#100981).) - (Fix pidfile directory in samab.log) - (Remove obsolete samba-3.0.0beta2.tar.bz2.md5 file) - (Move libsmbclient to the -common package (#99449)) * Sun Jun 22 2003 Nalin Dahyabhai <nalin@redhat.com> 2.2.8a-4 - rebuild * Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com> - rebuilt * Wed May 28 2003 Jay Fenlason <fenlason@redhat.com> 2.2.8a-2 - add libsmbclient.so for gnome-vfs-extras - Edit specfile to specify /var/run for pid files - Move /tmp/.winbindd/socket to /var/run/winbindd/socket * Wed May 14 2003 Florian La Roche <Florian.LaRoche@redhat.de> - add proper ldconfig calls * Thu Apr 24 2003 Jay Fenlason <fenlason@redhat.com> 2.2.8a-1 - upgrade to 2.2.8a - remove old .md5 files - add "pid directory = /var/run" to the smb.conf file. Fixes #88495 - Patch from jra@dp.samba.org to fix a delete-on-close regression
2004-09-09 12:08:44 +00:00
eval acct_file=\${$#}
spool_dir=`dirname $acct_file`
config_file=$spool_dir/.config
# Should read the following variables set in the config file:
# share
# hostip
# user
# password
eval `cat $config_file`
share=`echo $share | sed "s/[\]/\//g"`
if [ "$user" != "" ]; then
usercmd="-U"
else
usercmd=""
fi
if [ "$workgroup" != "" ]; then
workgroupcmd="-W"
else
workgroupcmd=""
fi
if [ "$translate" = "yes" ]; then
command="translate ; print -"
else
command="print -"
fi
#echo $share $password $translate $x_command > /tmp/smbprint.log
cat | /usr/bin/smbclient "$share" "$password" -E ${hostip:+-I} \
$hostip -N -P $usercmd "$user" $workgroupcmd "$workgroup" \
-c "$command" 2>/dev/null