#!/bin/bash
#resetprinting
#This resets the printer system in the same manor as the GUI reset printers works
#v1.0 Daniel Shane 27/06/14
#Check we are root
if [ $EUID != 0 ]
then
echo "`basename $0` MUST run as root..."
exit 1
fi
#Remove all Printers from CUPS
for file in /etc/cups/ppd/* ; do
path=${file%.ppd}
name=${path##*/}
lpadmin -x $name &> /dev/null
done
#Loop RM of All Users printers .apps
ls -1 "$3"/Users/ | while read useris
do
rm -rf "$3"/Users/"$useris"/Library/Printers/* &> /dev/null
done
#Reset CUPS
launchctl stop org.cups.cupsd
rm /etc/cups/cupsd.conf &> /dev/null
cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf &> /dev/null
rm /etc/cups/printers.conf &> /dev/null
rm /Library/Printers/InstalledPrinters.plist &> /dev/null
launchctl start org.cups.cupsd
exit 0
#resetprinting
#This resets the printer system in the same manor as the GUI reset printers works
#v1.0 Daniel Shane 27/06/14
#Check we are root
if [ $EUID != 0 ]
then
echo "`basename $0` MUST run as root..."
exit 1
fi
#Remove all Printers from CUPS
for file in /etc/cups/ppd/* ; do
path=${file%.ppd}
name=${path##*/}
lpadmin -x $name &> /dev/null
done
#Loop RM of All Users printers .apps
ls -1 "$3"/Users/ | while read useris
do
rm -rf "$3"/Users/"$useris"/Library/Printers/* &> /dev/null
done
#Reset CUPS
launchctl stop org.cups.cupsd
rm /etc/cups/cupsd.conf &> /dev/null
cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf &> /dev/null
rm /etc/cups/printers.conf &> /dev/null
rm /Library/Printers/InstalledPrinters.plist &> /dev/null
launchctl start org.cups.cupsd
exit 0