Created
January 27, 2018 08:09
-
-
Save lucascantor/9e6e37fdc4f0bb4e3a10f82d57d49d23 to your computer and use it in GitHub Desktop.
Reset printing system to factory defaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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