Monday, November 22, 2010

Part III - Cups and Windows Drivers - Automagically delicious!

Primer

Wow, this one has been a long time in coming. Call it lack of motivation,
writing 3 other blog posts, or I realized just how much of a PITA it is
to actually get this up and running. Either way, here you go.

Part III focuses on being able to connect to your cups server via samba,
and have the samba/cups server automatically push out the necessary drivers
for your printer. Once again, keep in mind that this was done on an
ubuntu/debian server; so mileage may vary.

First thing you want to do is install the necessary packages to get samba
installed and configured properly. There are plenty of GUI tools out there
to help you setup samba (swat, and some gui utility to setup samba from gnome
are two that come to mind). But alas, it's easier for me to know what actually
goes into a configuration file if I do it from the command line and edit
the smb.conf file. So that's what I'll be doing here in this blog post.

So, first things first: install samba and other necessary apps:

a. apt-get install samba samba-common samba-common-bin
b. download the cups windows drivers from cup's web page
1. wget http://www.cups.org/software.php?VERSION=1.4.5&FILE=cups/windows/cups-windows-6.0-source.tar.gz

Configuring Samba and Cups Services

Once samba is installed, time to play with the configuration, navigate to
/etc/samba/ and open up smb.conf
1. vim /etc/samba/smb.conf

Now, because my network may be slightly different than yours, I will
pastebin what my smb.conf file looks like; the main thing to worry about
is the print share, this is where samba and cups talk to each other about
the necessary printer drivers and whatnot. I know at first glance, it may
look like there are two printer shares, but one is for the window's printers
to view the printers, and the other is print$ that talks to cups. Both very necessary pieces of information.

Pastebin of smb.conf:
http://www.pastebin.ca/1999380


Once you have successfully setup smb, and tested with: testparm /etc/samba/smb.conf
then it's time to move on to the next step.

** Side Note: I have read on the internet that the following lines should
be put into your /etc/cups/cupsd.conf file, but have found for whatever
reason that it's not necessary on the setup that I use, but if your having
problems printing; you might want to add these lines into your cupds.conf file


mime.convs:
application/octet-stream application/vnd.cups-raw 0 -

mime.types:
application/octet-stream




After you have setup smb.conf file, there are a few more steps necessary
to get samba to play nice with your printers


a) mkdir -m 777 /var/spool/samba
b) Create a samba user, you can use root, or another use
1) smbpasswd -a root

Get Windows print drivers & Install the cups/samba magic

A) Extract/Build Windows Cups drivers


Okay, I assume you went out and downloaded the Cups drivers (see Introduction); and you followed my steps in
Part 1 of this (putting the proper .ppd file in place for your printer) Now you
need to build the necessary drivers for cups/windows magic.


a) cd to the download directory where you put the cups-windows-source
b) extract the file
  1) tar zxvf cups-windows-6.0-source.tar.gz
c) Navigate to your new directory
  1) cd cups-windows-6.0
d) build packages
  make install


When you run make install, you should see something simliar to this:
Creating directory /usr/share/cups/drivers...
Installing cups6.inf...
Installing cups6.ini...
Installing cupsps6.dll...
Installing cupsui6.dll...


B) Retrieve Windows postscript files from a Windows machine


Now here comes the tricky part. In the past you were able to just get adobe postscript files and use these to generate what was
needed for cups to frolic hand in hand with Windows Operating Systems. Now, through much searching, I have been unable to locate
a valid download from adobe that would work with my Windows 7 machine. So we have to go about this the hard way. Was there ever
really an easy way to this? I mean come-on, this is a 3-part series.


1. As I said, this is the tricky part; the easiest way I found (on both windows vista, 7 and xp) was to find a printer in add/remove
printers that used postscript drivers, and was somewhat similar to the printer that I was going to be using (not necessary, force of
habit no doubt). Once this 'fake' printer was installed, I did a search for the files that I would need for adding to the cups server.


Windows 7/Vista/XP:
cups6.ini
cupsps6.dll
cupsui6.dll
ps5ui.dll
pscript5.dll
pscript.hlp
pscript.ntf



2. Once you have located ALL of these files; scp them over to /usr/share/cups/drivers on the cups server; make sure that they are all lowercase.



And now the magic begins. Before you begin this next step, make sure you created a samba user as outlined earlier. Also, you need to edit your /etc/samba/smb.conf
and modify security = share, to security = user for this next step. Don't forget to change it back to 'security = share' once you have completed this step, or restarting
samba for the changes to take effect.



**Note - I also found through various research, if you have more than 1 samba server on your network, you need to bring the one you are working on, network interface down
(ifconfig dev down) for the duration of the next few steps.



C) Run the following commands to export cups drivers


1. cupsaddsmb -H localhost -U root -a -v
2. At this point, enter your password, if all is good..you should see a whole boatload of data coming across your screen (hopefully all good) talking about
grabbing the PPD file for your printer (see Part 1) and adding all sorts of cups/samba magic to make everything work.

Once this is complete, DON'T FORGET to change 'security = user' back to 'security = share' or your going to have some problems when it comes to adding printers

** Note - I found that you need to get necessary windows files as separate entities for 32bit and 64bit OS's. So if you have both a 32bit windows host and a 64bit windows host;
you need to get the same dll's (and other files as illustrated above) and run the cupsaddsmb command against both (just put the in different directories prior to running cupsaddsmb)




Testing Out



Final test, and a quick one at that. Fire up your windows client. Now you have two options, you can either add the printer through the add printer wizard, or via \\hostname\printers.
Either one should automagically show the printer in question, allowing you to add the printer to your windows client without having to add print drivers.



Now my reasoning behind this? Well if you really got this far in the blogpost; then I'm sure your curious just why I went through all of this just for a print server at the house.
Well, between work laptops, friends and family that come visit, and odd-ball machines that I tend to work on; it's easier and much less stressful for people that want to print, to
just browse the print share and add the printer; rather than me hunting down my Driver CD and hoping it's compatible with whatever flavor of windows that currently resides
on someone's computer. That and it gets away from installing all of the unnecessary 'junk' that most of the printer CD's come with; when all the person want's to do is print
out a page or two from a website.

Anyway, that concludes part III of Samba and Cups. Holy crap, I realize it took forever (and 2 other blog posts) but as you can see, it was a large work in progress, documenting every one of
my little steps along the way.

19 comments:

  1. I followed these instructions using Centos 6.3 and an HP P2035n printer. I was able to connect to the printer with no issues but when I tried to print all I get are pages and pages of text I do not understand.

    ReplyDelete
  2. Excellent post and wonderful blog, I really like this type of interesting articles keep it u
    123hpremoteassistance Officejet 7511 Printer Setup

    ReplyDelete
  3. Thank you, can you please provide me details on system issues you foresee while you install a printer, any external software to be downloaded?

    HP Officejet 7511

    ReplyDelete
  4. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
    Hp Officejet 7511 Wireless Setup

    ReplyDelete
  5. Good technique for Cups and Windows Drivers - Automagically delicious!. Thanks for sharing 123hp-com.us

    ReplyDelete
  6. A very interesting article. The insights are really helpful and informative. Thanks for posting.


    123.hp.com/envy6200

    ReplyDelete
  7. This post is really informative, We provide complete steps to fix HP DeskJet printer offline error. Visit 123 helpline to read more post.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete