Skip to content

Instantly share code, notes, and snippets.

@lucascantor
Created January 27, 2018 08:09
Show Gist options
  • Save lucascantor/9e6e37fdc4f0bb4e3a10f82d57d49d23 to your computer and use it in GitHub Desktop.
Save lucascantor/9e6e37fdc4f0bb4e3a10f82d57d49d23 to your computer and use it in GitHub Desktop.
Reset printing system to factory defaults
#!/bin/bash
# Stop CUPS
launchctl stop org.cups.cupsd
# Backup the InstalledPrinters plist
if [ -e "/Library/Printers/InstalledPrinters.plist" ]
then
mv /Library/Printers/InstalledPrinters.plist /Library/Printers/InstalledPrinters.plist.bak
fi
# Backup the CUPS config
if [ -e "/etc/cups/cupsd.conf" ]
then
mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.bak
fi
# Restore the default config by copying it
if [ ! -e "/etc/cups/cupsd.conf" ]
then
cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf
fi
# Backup the printers config file
if [ -e "/etc/cups/printers.conf" ]
then
mv /etc/cups/printers.conf /etc/cups/printers.conf.bak
fi
# Start CUPS
launchctl start org.cups.cupsd
# Remove all printers
lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment