Skip to content

Instantly share code, notes, and snippets.

@HBBisenieks
Created September 12, 2014 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HBBisenieks/4abb5ad767ad1e6676ed to your computer and use it in GitHub Desktop.
Save HBBisenieks/4abb5ad767ad1e6676ed to your computer and use it in GitHub Desktop.
Printer Deployment Script
#!/bin/sh
# Takes a list of printers in the form
# System Name, Display Name, Model, Location, Address
# and adds them to the system, extrapolating required driver
# and installing drivers as needed
if [ ! "$1" ]; then
echo
echo " Usage: ${0##*\/} list-of-printers.csv"
echo " takes as its only argument a csv in the form"
echo " printer_name, display_name, location, address, model"
echo " and adds those printer to the local system,"
echo " downloading drivers as required."
echo
echo " Address is simply an IP address; the script appends"
echo " the appropriate protocol on a per-printer basis."
echo
exit 2
fi
IFS=","
# Determine proper driver based on model name
# This script only knows about a limited number
# of printers.
while read printername gui_display_name location address model ; do
driver_ppd="/Library/Printers/PPDs/Contents/Resources/"
case $model in
"HP 1022")
driver="HP LaserJet 1022.gz"
address="socket://"$address
;;
"HP 1300")
driver="hp LaserJet 1300 series.gz"
address="socket://"$address
;;
"HP 1320")
driver="HP LaserJet 1320 Series.gz"
address="socket://"$address
;;
"HP 2015")
driver="HP LaserJet P2015.gz"
address="socket://"$address
;;
"HP 2420")
driver="HP LaserJet 2420.gz"
address="socket://"$address
;;
"HP 2500")
driver="HP LaserJet 2500.gz"
address="socket://"$address
;;
"HP 3005")
driver="HP LaserJet P3005.gz"
address="socket://"$address
;;
"HP 4050")
driver="HP LaserJet 4050 Series.gz"
address="socket://"$address
;;
"HP 4650")
driver="hp color LaserJet 4650.gz"
address="socket://"$address
;;
"HP CP3505n")
driver="HP Color LaserJet CP3505.gz"
address="socket://"$address
;;
"HP M602")
driver="HP LaserJet 600 M601 M602 M603.gz"
address="socket://"$address
;;
"HP P2015")
driver="HP LaserJet P2015.gz"
address="socket://"$address
;;
"HP P2055dn")
driver="HP LaserJet P2055.gz"
address="socket://"$address
;;
"Savin 9060")
driver="SAVIN 9060.gz"
address="lpd://"$address
;;
*)
echo "ERROR: \"$model\" is Invalid"
;;
esac
driver_ppd=$driver_ppd$driver
done < $1
echo "Done adding printers."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment