this is obsolete doc -- see http://doc.nethence.com/ instead

Setting up a Samba and BSD powered print spooler 

 

Dealing with the printer 

On NetBSD, make sure you can send something to the printer e.g., 

  echo "check line 1\ncheck line 2" > /dev/lpa0 

Note. it's best to use the lpa driver instead of lpt. 

 

Enable and start the line printer spooler daemon, 

cd /etc/
cat >> rc.conf <<EOF9  
lpd=yes
lpd_flags=""
EOF9
rc.d/lpd start

note. here I also remove the default -s flag so the daemon also listens on TCP. 

now make sure it is running, 

ps auxw | grep lpd

 

Eventually make a symlink to define the default printer device (in /dev/, 'lp' stands for Local Printer or Line Printer, I don't know), 

cd /dev/
ln -s lpa0 lp

 

Try to print with the default printer ('lp' in printcap for Local Printer), 

cd ~/
echo "check line 1\ncheck line 2" | lpr -P lp

 

Prepare the spool directory for your printer, I am naming mine 'laserjet4l', 

cd /var/spool/lpd/

mkdir -p laserjet4l/ 

chown daemon:daemon laserjet4l/ 

chmod 770 laserjet4l/ 

Ref. http://www.netbsd.org/docs/guide/en/chap-print.html 

 

Configure printcap (removing the old one with multiples printer configurations so samba won't show them), 

cd /etc/
mv printcap printcap.dist
vi printcap

like, 

laserjet4l|HP LaserJet 4L:\
        :sh:lp=/dev/lpa0:sd=/var/spool/lpd/laserjet4l:lf=/var/log/lpd-errs:\
        :ff=:

Note. the sh: parameter supresses the burst page. This actually *is* usefull (redundant and non exclusive with lpr -h but the latter isn't generally used). 

Note. I had to force empty FormField so I don't get an additional blank page every time I print something. This Formfield is only a specificly enabled feature on BSD. 

Note. There is no need to reload or restart LPD after editing the printcap configuration. 

 

Ready to go for that part, try to print something with your new printcap configuration, 

  echo "check line 1\ncheck line 2" | lpr -P laserjet4l 

 

Dealing with the network share 

Prepare the spooling folder for the samba print jobs to be written, 

mkdir -p /var/spool/samba/
chmod 1777 /var/spool/samba/

 

Prepare the driver folders for windows clients to upload and download them, 

mkdir -p /var/samba/drivers/
cd /var/samba/drivers/
mkdir -p COLOR/
mkdir -p IA64/
mkdir -p W32ALPHA/
mkdir -p W32MIPS/
mkdir -p W32PPC/
mkdir -p W32X86/2/
mkdir -p W32X86/3/
mkdir -p WIN40/
mkdir -p x64/

default permissions and root ownership are just fine. 

 

Configure the Samba daemon to share your printer, 

cd /etc/
ln -s /usr/pkg/etc/samba
cd /etc/samba/

like (note this is in 'share' mode, you could also remove the 'guest ok' lines and use the 'user' mode), 

[global]

workgroup = <WORKGROUP_OR_DOMAIN> 

 server string = Samba %v (%h)
 #security = user
 security = share
 guest account = nobody
 load printers = yes
 printing = bsd
 printcap name = /etc/printcap
 force printername = yes

 

[printers]
 comment = Printers
 printable = yes
 browseable = yes
 public = yes
 read only = yes
 use client driver = no

path = /var/spool/samba 

 

[print$]
 comment = Printer drivers
 browseable = yes
 public = yes
 read only = yes
 write list = root
 printer admin = root
 inherit permissions = yes

path = /var/samba/drivers 

Note. read only = yes on the [print$] share doesn't harm, root is still able to write in it. 

 

Add the root user to the samba credentials (see below in the uploading drivers section why I am using the root account), 

smbpasswd -a root

 

Apply your Samba configurations, 

/etc/rc.d/lpd restart
/etc/rc.d/smbd restart
/etc/rc.d/nmbd restart
/etc/rc.d/winbindd restart

or reload (for minor changes), 

/etc/rc.d/lpd restart
/etc/rc.d/smbd reload
/etc/rc.d/nmbd reload
/etc/rc.d/winbindd reload

 

Uploading the freaking windows drivers to the samba server 

This is a bit more tricky for Unix admins. You need to connect from a Windows box with a user that has write permissions to the [print$] share to upload the drivers and then, and only then, you can connect as guest or normal user to install the printer without having to choose the driver yourself. I just had the best success with the root samba user. 

 

Temporarily switch the samba configuration to security = user (the public = yes parameters can stay), 

cd /etc/samba/
vi smb.conf

change temporarily, 

 security = user

and apply, 

/etc/rc.d/lpd restart
/etc/rc.d/smbd reload
/etc/rc.d/nmbd reload
/etc/rc.d/winbindd reload

 

Now make sure you've got write access to some of these folder by accessing the print$ network share from a windows client NOT AS GUEST BUT AS ROOT, 

Explorer > Tools > Connect to a network drive
\\<print server>\print$\
as... root user
and try to copy a file to some driver folder

 

And connect to the server network share (still logged in as root), 

\\<print server>\
DO NOT CLICK ON THE PRINTER RIGHT NOW
DOUBLE-CLICK ON PRINTERS AND FAXES
THEN RIGHT CLICK ON THE PRINTER IN THAT FOLDER > PROPERTIES
ANSWER NO to go directly to the properties window (if everything is greyed out see the troubleshooting chapter)
first, go to the Advanced tab and click New driver... install the corresponding printer driver,
then go to the Share tab > Additional drivers... and verify that the local type of Windows system you are running is currently selected,
do the same with other kinds of Windows clients.

 

This worked with Windows XP. For Windows XP 64-bit however, the driver isn't found, just copy the driver yourself, e.g. for HP Laserjet 4L, 

C:\WINDOWS\system32\spool\drivers\x64\3\HPLJ4L.GPD
C:\WINDOWS\system32\spool\drivers\x64\3\PCL5ERES.DLL
C:\WINDOWS\system32\spool\drivers\x64\3\STDNAMES.GPD
C:\WINDOWS\system32\spool\drivers\x64\3\TTFSUB.GPD
C:\WINDOWS\system32\spool\drivers\x64\3\UNIDRV.DLL
C:\WINDOWS\system32\spool\drivers\x64\3\UNIDRV.HLP
C:\WINDOWS\system32\spool\drivers\x64\3\UNIDRVUI.DLL
C:\WINDOWS\system32\spool\drivers\x64\3\UNIRES.DLL

note. and you can get the other files (starting with AGACCST1.PPD using the Additional drivers... button first -- it doesn't install the printer drivers but that other shit, though). 

to, 

<[print$] network drive>\x64\3\

Note. It should be the other way around... on a 64-bit machine you should be able to install both, 32 and 64 bit drivers at once and more easyly. 

 

Now make sure the drivers have been uploaded on the server side, 

find /var/samba/

 

Switch back to security = share if you like, 

cd /etc/samba/
vi smb.conf

change temporarily, 

 security = share

and apply, 

/etc/rc.d/lpd restart
/etc/rc.d/smbd reload
/etc/rc.d/nmbd reload
/etc/rc.d/winbindd reload

 

Restart the used Windows clients to get rid of the 'root' connection and use normal users or even guest (security = share) mode. 

 

Troubleshooting 

If everything is greyed out when accessing the the shared printer properties, 

- make sure you're in the right "Printer and faxes" folder, 

- make sure the samba service is in 'user' security mode, at least temporarily, 

- make sure you're logged in as 'root' (previous connection to [print$] to check the write access will do. 

 

References 

Chapter 12. Printing 

http://www.netbsd.org/docs/guide/en/chap-print.html 

 

4. Sharing Printers With Windows PCs 

http://www.tldp.org/HOWTO/Debian-and-Windows-Shared-Printing/sharing_with_windows.html 

 

Uploading Printer Drivers to Samba Servers 

http://www.samba.org/samba/docs/man/Samba-Guide/happy.html#id2582657 

 

Manual Driver Installation in 15 Steps 

http://www.linuxtopia.org/online_books/network_administration_guides/samba_reference_guide/29_CUPS-printing_105.html 

 

Point and Print in Samba 

http://www.netadmintools.com/art258.html 

 

Samba / Serveur d'impression 

http://wiki.zionetrix.net/informatique:reseau:samba:serveur_impression 

 

Que faire si les pilotes ne veulent plus se copier sur le serveur ? 

http://rezotice.ac-lyon.fr/faq/index.php?action=artikel&cat=5&id=47&artlang=fr 

 

Serveur d'impression (cups + samba) sur debian 6.0 

http://wiki.kogite.fr/index.php/Serveur_d%27impression_%28cups_%2B_samba%29_sur_debian_6.0