Automate printer setup with NetRestore's PHPServices

May 08, '07 07:30:00AM

Contributed by: thehigherlife

I wanted a way to automatically set up a printer without having to touch the machine and after much work, I did it (with a little help from some friends). Here are the steps I used in order to get it to work. Your mileage may vary, and this isn't a post action, since some of the commands aren't included on a default NetBoot image. You'll need Mike Bombich's excellent NetRestore

First, log into NetRestore's PHP services, and go to Database administration » Create Machine Specific Attributes. Add these specific field names (spelling and case counts!). The following is laid out in this order: field name | Data type | Default value (if any)...

Step two follows: Change the 'Machine Specific Settings for Machines' settings for the machines that you want the script to set up printers for.

Go to this URL...

http://your.netrestore.sever/nr/nr_machine_settings.php?hw=00:00:00:00:00:00
replace 00:00:00:00:00:00 with your machine's MAC address. Enter in the data for that machine for the fields you just created. Spaces aren't allowed in the printer_name, printer_location, or printer_address fields. They are allowed in the printer_driver field. For the printer_driver field, find the right file name by going to /Library » Printers » PPDs » Contents » Resources » en.lproj. You'll find the correct printer driver in that folder. For example, the one I needed to add was called HP LaserJet 4200 Series.gz.

Now you're all set up on the server side.

Client side setup

Copy the code for these two scripts into separate files, as named below: Save these two files somewhere on your client machine; wherever you see fit. Make sure you also set the proper variables correctly in the set-printers.sh file. Run set-printer.sh from the client, and the printer should be installed. Since my machines are frozen, I have it set up to run this script every time the computer starts up, so that it adds the printer based my settings in NetRestore's PHP services page.

Good luck to the rest of you...

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070504130353517