diff --git a/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh b/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh index d0b1208..1f48e23 100644 --- a/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh +++ b/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: jamf_CreatePrinters.sh # By: Zack Thompson / Created: 3/1/2018 -# Version: 0.3 / Updated: 3/6/2018 / By: ZT +# Version: 0.4 / Updated: 3/7/2018 / By: ZT # # Description: The purpose of this script is to assist Site Admins in creating Printers in Jamf without needing to use the Jamf Admin utility. # @@ -16,9 +16,6 @@ echo "***** CreatePrinters process: START *****" jamfPS="https://jss.company.com:8443" apiPrinters="${jamfPS}/JSSResource/printers/id" - # Add -k (--insecure) to disable SSL verification - curlAPI=(--silent --show-error --fail --user "${jamfAPIUser}:${jamfAPIPassword}" --write-out "statusCode:%{http_code}" --output - --header "Content-Type: application/xml" --request) - ################################################## # Setup Functions @@ -62,7 +59,8 @@ createPrinter() { # Read the printer info into variables. while IFS="," read -r printerName printerCUPsName printerLocation printerIP printerModel; do if [[ -e "/private/etc/cups/ppd/${printerCUPsName}.ppd" ]]; then - printerPPDContents=$(printf "/private/etc/cups/ppd/${printerCUPsName}.ppd") + printerPPDFile=$(printf "/private/etc/cups/ppd/${printerCUPsName}.ppd") + printerPPDContents=$(cat "${printerPPDFile}" | sed 's/&/\&/g; s//\>/g; s/"/\"/g; s/'"'"'/\'/g' ) else informBy "Unable to locate the PPD file -- unable to create the printer." return @@ -71,13 +69,14 @@ createPrinter() { # POST changes to the JSS. curlReturn="$(/usr/bin/curl "${curlAPI[@]}" POST ${apiPrinters}/0 --data " $printerName +Printers ${printerIP} ${printerCUPsName} ${printerLocation} ${printerModel} Created by ${createdByUser} running the jamf_CreatePrinters.sh script. ${printerCUPsName}.ppd -$(cat ${printerPPDContents}) +${printerPPDContents} /Library/Printers/PPDs/Contents/Resources/${printerCUPsName}.ppd ")" @@ -141,6 +140,9 @@ informBy() { createdByUser="${3}" jamfAPIUser=$(DecryptString $5 'Salt' 'Passphrase') jamfAPIPassword=$(DecryptString $6 'Salt' 'Passphrase') + + # Add -k (--insecure) to disable SSL verification + curlAPI=(--silent --show-error --fail --user "${jamfAPIUser}:${jamfAPIPassword}" --write-out "statusCode:%{http_code}" --output - --header "Content-Type: application/xml" --request) else action="${1}" ranBy="CLI"