-
Install the printer on CUPS.
root#
lpadmin -p mysmbtstprn -v socket://10.160.51.131:9100 -E \
-P canonIR85.ppd
This installs a printer with the name
mysmbtstprn
to the CUPS system. The printer is accessed via a socket
(a.k.a. JetDirect or Direct TCP/IP) connection. You need to be root
for this step.
-
(Optional.) Check if the printer is recognized by Samba.
root#
rpcclient -Uroot%xxxx -c 'enumprinters' localhost \
| grep -C2 mysmbtstprn
flags:[0x800000]
name:[\\kde-bitshop\mysmbtstprn]
description:[\\kde-bitshop\mysmbtstprn,,mysmbtstprn]
comment:[mysmbtstprn]
This should show the printer in the list. If not, stop and restart the Samba daemon (smbd) or send a HUP signal:
root#
kill -HUP `pidof smbd`
Check again. Troubleshoot and repeat until successful. Note the “empty” field between the two
commas in the “description” line. The driver name would appear here if there was one already. You
need to know root's Samba password (as set by the
smbpasswd
command) for this step and most
of the following steps. Alternatively, you can authenticate as one of the users from the “write
list” as defined in smb.conf
for
[print$]
.
-
(Optional.) Check if Samba knows a driver for the printer.
root#
rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2'\
localhost | grep driver
drivername:[]
root#
rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' \
localhost | grep -C4 driv
servername:[\\kde-bitshop]
printername:[\\kde-bitshop\mysmbtstprn]
sharename:[mysmbtstprn]
portname:[Samba Printer Port]
drivername:[]
comment:[mysmbtstprn]
location:[]
sepfile:[]
printprocessor:[winprint]
root#
rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost
result was WERR_UNKNOWN_PRINTER_DRIVER
None of the three commands shown above should show a driver.
This step was done for the purpose of demonstrating this condition. An
attempt to connect to the printer at this stage will prompt a
message along the lines of, “The server does not have the required printer
driver installed.”
-
Put all required driver files into Samba's
[print$].
root#
smbclient //localhost/print\$ -U 'root%xxxx' \
-c 'cd W32X86; \
put /etc/cups/ppd/mysmbtstprn.ppd mysmbtstprn.PPD; \
put /usr/share/cups/drivers/cupsui.dll cupsui.dll; \
put /usr/share/cups/drivers/cupsdrvr.dll cupsdrvr.dll; \
put /usr/share/cups/drivers/cups.hlp cups.hlp'
(This command should be entered in one long single line. Line breaks and the line ends indicated by
“\” have been inserted for readability reasons.) This step is
required
for
the next one to succeed. It makes the driver files physically present in the
[print$]
share. However, clients would still not be able to install them, because Samba does not yet treat them as
driver files. A client asking for the driver would still be presented with a “not installed here”
message.
-
Verify where the driver files are now.
root#
ls -l /etc/samba/drivers/W32X86/
total 669
drwxr-sr-x 2 root ntadmin 532 May 25 23:08 2
drwxr-sr-x 2 root ntadmin 670 May 16 03:15 3
-rwxr--r-- 1 root ntadmin 14234 May 25 23:21 cups.hlp
-rwxr--r-- 1 root ntadmin 278380 May 25 23:21 cupsdrvr.dll
-rwxr--r-- 1 root ntadmin 215848 May 25 23:21 cupsui.dll
-rwxr--r-- 1 root ntadmin 169458 May 25 23:21 mysmbtstprn.PPD
The driver files now are in the W32X86 architecture “root” of
[print$]
.
-
Tell Samba that these are driver files (
adddriver
).
root#
rpcclient -Uroot%xxxx -c 'adddriver "Windows NT x86" \
"mydrivername:cupsdrvr.dll:mysmbtstprn.PPD: \
cupsui.dll:cups.hlp:NULL:RAW:NULL"' \
localhost
Printer Driver mydrivername successfully installed.
You cannot repeat this step if it fails. It could fail even as a result of a simple typo. It will most likely
have moved a part of the driver files into the “2” subdirectory. If this step fails, you need to
go back to the fourth step and repeat it before you can try this one again. In this step, you need to choose a
name for your driver. It is normally a good idea to use the same name as is used for the printer name;
however, in big installations you may use this driver for a number of printers that obviously have different
names, so the name of the driver is not fixed.
-
Verify where the driver files are now.
root#
ls -l /etc/samba/drivers/W32X86/
total 1
drwxr-sr-x 2 root ntadmin 532 May 25 23:22 2
drwxr-sr-x 2 root ntadmin 670 May 16 03:15 3
root#
ls -l /etc/samba/drivers/W32X86/2
total 5039
[....]
-rwxr--r-- 1 root ntadmin 14234 May 25 23:21 cups.hlp
-rwxr--r-- 1 root ntadmin 278380 May 13 13:53 cupsdrvr.dll
-rwxr--r-- 1 root ntadmin 215848 May 13 13:53 cupsui.dll
-rwxr--r-- 1 root ntadmin 169458 May 25 23:21 mysmbtstprn.PPD
Notice how step 6 also moved the driver files to the appropriate
subdirectory. Compare this with the situation after step 5.
-
(Optional.) Verify if Samba now recognizes the driver.
root#
rpcclient -Uroot%xxxx -c 'enumdrivers 3' \
localhost | grep -B2 -A5 mydrivername
Printer Driver Info 3:
Version: [2]
Driver Name: [mydrivername]
Architecture: [Windows NT x86]
Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
Remember, this command greps for the name you chose for the
driver in step 6. This command must succeed before you can proceed.
-
<title>Tell Samba which printer should use these driver files (
setdriver
).</title>
root#
rpcclient -Uroot%xxxx -c 'setdriver mysmbtstprn mydrivername' \
localhost
Successfully set mysmbtstprn to driver mydrivername
Since you can bind any printer name (print queue) to any driver, this is a convenient way to set up many
queues that use the same driver. You do not need to repeat all the previous steps for the setdriver command to
succeed. The only preconditions are that
enumdrivers
must find the driver and
enumprinters
must find the printer.
-
(Optional) Verify if Samba has recognized this association.
root#
rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
| grep driver
drivername:[mydrivername]
root#
rpcclient -Uroot%xxxx -c 'getprinter mysmbtstprn 2' localhost \
| grep -C4 driv
servername:[\\kde-bitshop]
printername:[\\kde-bitshop\mysmbtstprn]
sharename:[mysmbtstprn]
portname:[Done]
drivername:[mydrivername]
comment:[mysmbtstprn]
location:[]
sepfile:[]
printprocessor:[winprint]
root#
rpcclient -U root%xxxx -c 'getdriver mysmbtstprn' localhost
[Windows NT x86]
Printer Driver Info 3:
Version: [2]
Driver Name: [mydrivername]
Architecture: [Windows NT x86]
Driver Path: [\\kde-bitshop\print$\W32X86\2\cupsdrvr.dll]
Datafile: [\\kde-bitshop\print$\W32X86\2\mysmbtstprn.PPD]
Configfile: [\\kde-bitshop\print$\W32X86\2\cupsui.dll]
Helpfile: [\\kde-bitshop\print$\W32X86\2\cups.hlp]
Monitorname: []
Defaultdatatype: [RAW]
Monitorname: []
Defaultdatatype: [RAW]
root#
rpcclient -Uroot%xxxx -c 'enumprinters' localhost \
| grep mysmbtstprn
name:[\\kde-bitshop\mysmbtstprn]
description:[\\kde-bitshop\mysmbtstprn,mydrivername,mysmbtstprn]
comment:[mysmbtstprn]
Compare these results with the ones from steps 2 and 3. Every one of these commands show the driver is installed. Even
the
enumprinters
command now lists the driver
on the “description” line.
-
(Optional.) Tickle the driver into a correct
device mode.
You certainly know how to install the driver on the client. In case
you are not particularly familiar with Windows, here is a short
recipe: Browse the Network Neighborhood, go to the Samba server, and look
for the shares. You should see all shared Samba printers.
Double-click on the one in question. The driver should get
installed and the network connection set up. Another way is to
open the Printers (and Faxes) folder, right-click on the printer in
question, and select Connect or Install. As a result, a new printer
should appear in your client's local Printers (and Faxes)
folder, named something like printersharename on Sambahostname.
It is important that you execute this step as a Samba printer admin
(as defined in smb.conf
). Here is another method
to do this on Windows XP. It uses a command line, which you may type
into the “DOS box” (type root's smbpassword when prompted):
C:\>
runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry \
/in /n \\sambaserver\mysmbtstprn"
Change any printer setting once (like changing
portrait to
landscape
), click on Apply, and change the setting back.
-
Install the printer on a client (Point'n'Print).
C:\>
rundll32 printui.dll,PrintUIEntry /in /n "\\sambaserver\mysmbtstprn"
If it does not work, it could be a permissions problem with the
[print$]
share.
-
(Optional) Print a test page.
C:\>
rundll32 printui.dll,PrintUIEntry /p /n "\\sambaserver\mysmbtstprn"
Then hit [TAB] five times, [ENTER] twice, [TAB] once, and [ENTER] again, and march to the printer.
-
(Recommended.) Study the test page.
Hmmm. Just kidding! By now you know everything about printer installations and you do not need to read a word.
Just put it in a frame and bolt it to the wall with the heading "MY FIRST RPCCLIENT-INSTALLED PRINTER"
why not just throw it away!
-
(Obligatory.) Enjoy. Jump. Celebrate your success.
root#
echo "Cheeeeerioooooo! Success..." >> /var/log/samba/log.smbd