Skip to content

Instantly share code, notes, and snippets.

@krispayne
Last active April 26, 2017 10:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krispayne/f46414d746b706a059e1 to your computer and use it in GitHub Desktop.
Save krispayne/f46414d746b706a059e1 to your computer and use it in GitHub Desktop.
Bash script to deploy printer via JAMF Casper
#!/bin/bash
# Original: https://jamfnation.jamfsoftware.com/discussion.html?id=14467
# Useful script for deploying printers in a Casper Environment
# Originally by Lwindram on JAMF Nation forums
# https://jamfnation.jamfsoftware.com/viewProfile.html?userID=11026
# Edited to use JSS Script Parameters to make the script portable to all Models. Define $vars in JSS Policy.
## Translations
# man lpadmin
# -p = Named printer or class
# -v = device URI
# -D = textual description of destination
# -L = location of destination
# -m = model (ppd)
# -E (at end) enables device
## man lpoptions
# -o printer-is-shared=false disables sharing
# -o Duplex=None disables two-sided printing
# -o Duplex=DuplexNoTumble enables two-sided printing long edge
# -o Duplex=DuplexTumble enables two-sided printing short edge
## Variables
# PPD = $4 in JSS
ppd=${4}
# CUPS Name = $5 in JSS
cupsName=${5}
# Display Name = $6 in JSS
humanName=${6}
# IP Address and Protocol = $7 in JSS
# Be sure to add the protocol in the paramters!
ip=${7}
# Building Location = $8 in JSS
location=${8}
# Collation = $9 in JSS
# For HP Printers
#collation=${9}
# Tray 3 = $10 in JSS
#tray3=${10}
# $11 Use this for any other option. Large Capacity Tray, Binder, Etc.
#tray5=${11}
# PPD Base path e.g. "/Library/Printers/PPDs/Contents/Resources"
baseppd="/Library/Printers/PPDs/Contents/Resources"
# Script
lpadmin -p "$cupsName" -v $ip -D "$humanName" -L "$location" -m "$baseppd/$ppd" -E
lpadmin -p "$cupsName" -o printer-is-shared=false -o PageSize=Letter -o HPOption_Duplexer=True -o HPCollateSupported=True288 -o HPOption_Tray3=Tray3_500 -o HPOption_Tray4=Tray4_500 -o HPOption_Tray5=Tray5_1500
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment