#! /bin/bash #Created by Ryan Devine 5/1/07 #set-printers.sh #enter in these fields to match where you want your files to go / where they are myRecord=/tmp/myRecord.plist nrparse=~/Documents/smultronnotes/nrparse.py nrServer=http://yournetrestoreserver/nr #netrestore database group user name and password group=admin pass=password #gets the ethernet address of the current machine hw=`ifconfig en0 | awk '/ether/ { print $2 }'` #pulls down the plist file from your netrestore server to check which printer it should have curl --output "$myRecord" "$nrServer/netrestore.php?hw=$hw&gp=$group&p=$pass" #makes sure the file is downloaded before continuing if test -e "$myRecord" then #gets the values from the nrparse.py script and sets them to variables for this script printerAddress=`python $nrparse printer_address $myRecord` printerLocation=`python $nrparse printer_location $myRecord` printerName=` python $nrparse printer_name $myRecord` printerDriver=`python $nrparse printer_driver $myRecord` #outputs the values that the python script came up with. echo $printerAddress echo $printerLocation echo $printerName echo $printerDriver else exit fi #adds the printer the -o command is used to add attributes to the printer, i have duplexing enabled using the sides=two-sided-long-edge enabled, you can add your own here by just seaching google and finding out the correct attributes. lpadmin -p $printerName -L $printerLocation -E -v $printerAddress -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/$printerDriver" -o sides=two-sided-long-edge #makes the created printer the default printer lpoptions -d $printerName exit