Difference between revisions of "Add Printers Via Network Script"
Cytochromec (talk | contribs) |
(→Tweaking the default options) |
||
Line 75: | Line 75: | ||
− | == Tweaking the default options == | + | == Tweaking the default printing options == |
− | In some cases, you might want to change the default printing options. These options are driver dependent, so a fair amount of trial and error is needed. For our requirements, we found that our | + | In some cases, you might want to change the default printing options. These options are driver dependent, so a fair amount of trial and error is needed. |
+ | |||
+ | For our requirements, we found that our driver's default of 1200x1200 resolution was creating huge print jobs and overloading our network. The printers were also taking up enormous amounts of time to process each job. Using a couple of additional lpadmin commands solved the issue: | ||
lpadmin -p Room407 -v smb://192.168.1.9/Room407 -E -m drv:///hpcups.drv/hp-laserjet_p4515tn.ppd -L "ES 4th Floor Printer" | lpadmin -p Room407 -v smb://192.168.1.9/Room407 -E -m drv:///hpcups.drv/hp-laserjet_p4515tn.ppd -L "ES 4th Floor Printer" | ||
lpadmin -p Room407 -o OptionDuplex=True -o PageSize=A4 -o PrintoutMode=Normal.Gray -o Duplex=DuplexNoTumble -o printer-is-shared=false | lpadmin -p Room407 -o OptionDuplex=True -o PageSize=A4 -o PrintoutMode=Normal.Gray -o Duplex=DuplexNoTumble -o printer-is-shared=false | ||
lpadmin -p Room407 -o ColorModel=Grayscale -o PrinterResolution=300x300dpi | lpadmin -p Room407 -o ColorModel=Grayscale -o PrinterResolution=300x300dpi | ||
+ | |||
+ | These commands run in a very short time, and so we let them run every time in the updates.sh file. It encourages more environmentally friendly printing! |
Revision as of 19:09, 6 February 2013
If you have set up your ubermix computers to run the .network-autostart script (see Auto_Update_Script ) and look for an update.sh when they boot up, you can do updates and customization. One option is to have the correct printer pushed out to a computer based on its hostname.
Prerequisites:
- Network-autostart file set up on your image
- Computers are named with some convention based on location. This can be set after imaging, by choosing Advanced Options (5) and then Set device hostname (5). For example the convention, SCHOOLABBREVIATION-ROOM-COMPUTERNUMBER, would have computers named CES-A2-01 for a computer at Central Elementary School in Room A2.
Contents
First determine the correct printer driver
Open a terminal (ctrl-alt-t) and type
lpinfo --make-and-model 'Part of your printer model name here' -m
For example
lpinfo --make-and-model '1022n' -m
Will find the drivers for the HP Laserjet 1022n You will see a long list of text for multiple drivers, but the top one is the recommended driver
foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022n.ppd HP LaserJet 1022n Foomatic/foo2zjs-z1 (recommended) drv:///hpijs.drv/hp-laserjet_1022n-hpijs-pcl3.ppd HP LaserJet 1022n hpijs pcl3, 3.12.6, requires proprietary plugin drv:///hpijs.drv/hp-laserjet_1022n-hpijs-zjs.ppd HP LaserJet 1022n hpijs zjs, 3.12.6, requires proprietary plugin drv:///hpcups.drv/hp-laserjet_1022n-pcl3.ppd HP LaserJet 1022n pcl3, hpcups 3.12.6, requires proprietary plugin drv:///hpcups.drv/hp-laserjet_1022n-zjs.ppd HP LaserJet 1022n zjs, hpcups 3.12.6, requires proprietary plugin foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022nw.ppd HP LaserJet 1022nw Foomatic/foo2zjs-z1 (recommended) drv:///hpijs.drv/hp-laserjet_1022nw-hpijs-pcl3.ppd HP LaserJet 1022nw hpijs pcl3, 3.12.6, requires proprietary plugin drv:///hpijs.drv/hp-laserjet_1022nw-hpijs-zjs.ppd HP LaserJet 1022nw hpijs zjs, 3.12.6, requires proprietary plugin drv:///hpcups.drv/hp-laserjet_1022nw-pcl3.ppd HP LaserJet 1022nw pcl3, hpcups 3.12.6, requires proprietary plugin drv:///hpcups.drv/hp-laserjet_1022nw-zjs.ppd HP LaserJet 1022nw zjs, hpcups 3.12.6, requires proprietary plugin
You then copy the first bit of text all the way to .ppd In the laserjet example you would copy the following text and paste it in a text file for later foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022n.ppd
Second determine your printer ip address
Usually printers are set up with static IP addresses. If so you can ask your IT team for a list of IP addresses for printers. Also most printers will print out their configuration or have a display that will show the configuration. Printer IP addresses will be a series of 4 numbers separated by periods. For example, 10.6.64.103 Once you have the IP address you are ready to push out printers over the network
Edit the script
Here is the basic script that you can change with your site information. The terminal command that will add a printer looks like this:
lpadmin -p RoomA2 -v socket://10.6.64.103:9100 -m foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022n.ppd -L "Room A2" -E
Replace 4 pieces of information as shown below.
lpadmin -p ReplaceWithPrinterName -v socket://put-IP-address-here:9100 -m put-driver-.ppd-file-here -L "Put the location here" -E
Now once you have a correct line of code for each printer you can edit the script below to install a different printer to each set of computers. Edit the lines that say
if grep CES-A2 /etc/hostname
replacing "CES-A2" with the stem of the name for computers that all share the same printer. Replace the lpadmin line below that if statement wit the lpadmin line for your printer name, IP address, and driver. Change the lpadmin -d line to the same name as the printer you installed (this sets the printer as the default). Repeat this step for each room of computers. The following lines start with the word elif instead of if. If you need to add more room options just copy more blocks of 4 lines (elif, then, lpadmin -p, lpadmin -d).
The first if statement and the line near the end that start with "sudo echo" just make sure that each computer only runs this update once. If a computer is restored it will run the script and install the correct printer.
#!/bin/bash if [ ! -e /etc/cups/updated.txt ] then if grep CES-A2 /etc/hostname then lpadmin -p RoomA2 -v socket://10.6.64.103:9100 -m foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022n.ppd -L "Room A2" -E lpadmin -d RoomA2 elif grep CMS-D1 /etc/hostname then lpadmin -p RoomD1 -v socket://10.6.64.106:9100 -m foo2zjs:0/ppd/foo2zjs/HP-LaserJet_1022n.ppd -L "Room D1" -E lpadmin -d RoomD1 elif grep CMS-D8 /etc/hostname then lpadmin -p RoomD8 -v socket://10.6.64.102:9100 -m foo2zjs:0/ppd/foo2zjs/HP-LaserJet_Pro_P1606dn.ppd -L "Room D8" -E lpadmin -d RoomD8 fi sudo echo > /etc/cups/updated.txt fi
Tweaking the default printing options
In some cases, you might want to change the default printing options. These options are driver dependent, so a fair amount of trial and error is needed.
For our requirements, we found that our driver's default of 1200x1200 resolution was creating huge print jobs and overloading our network. The printers were also taking up enormous amounts of time to process each job. Using a couple of additional lpadmin commands solved the issue:
lpadmin -p Room407 -v smb://192.168.1.9/Room407 -E -m drv:///hpcups.drv/hp-laserjet_p4515tn.ppd -L "ES 4th Floor Printer" lpadmin -p Room407 -o OptionDuplex=True -o PageSize=A4 -o PrintoutMode=Normal.Gray -o Duplex=DuplexNoTumble -o printer-is-shared=false lpadmin -p Room407 -o ColorModel=Grayscale -o PrinterResolution=300x300dpi
These commands run in a very short time, and so we let them run every time in the updates.sh file. It encourages more environmentally friendly printing!