#!/bin/bash

# Delete all CHCS Printers
lpstat -p | cut -d" " -f2 | grep -iE 'CHCS_' | xargs -I{} lpadmin -x {}
echo "CHCS Printers Deleted.."

# Download DMG
curl -L "https://files.chapelhillchristianschool.org/Printer-Drivers/pc-print-deploy-client-10.80.10.15.dmg" > "/tmp/pc-print-deploy-client[10.80.10.15].dmg"

# Mount DMG
hdiutil attach /tmp/pc-print-deploy-client[10.80.10.15].dmg

# Install
installer -pkg /Volumes/PaperCut\ Print\ Deploy\ Client/PaperCut\ Print\ Deploy\ Client.pkg -target /

# Unmount DMG
hdiutil unmount /Volumes/PaperCut\ Print\ Deploy\ Client -force

# Delete DMG
rm "/tmp/pc-print-deploy-client[10.80.10.15].dmg"
