Reset CUPS printers at login

Oct 28, '03 09:58:00AM

Contributed by: dmorton

Problem:
Printers in computer labs are disappearing. It is a mix of students deleting them and Print Center losing them.

Solution:
An AppleScript that runs at login. The AppleScript removes printers that are in the Print Center. Then it copies your backup ppd folder into the Print Center ppd folder. It then deletes the printer.conf file and replaces it with the labprinters.conf file.

Setup Information:

  1. Set up your default printers in Print Center
  2. Make a copy of your /etc/cups/ppd folder and call it labppd
  3. Make a copy of your printers.conf file and call it labprinters.conf
  4. Open Script Editor and Enter the following text:
    
    tell application "Terminal"
      do shell script "rm -r /etc/cups/ppd" password ¬
       "root password" with administrator privileges
      do shell script "cp -r /etc/cups/labppds /etc/cups/ppd" password ¬
       "root password" with administrator privileges
      do shell script "rm /etc/cups/printers.conf" password ¬
       "root password" with administrator privileges
      do shell script ¬
       "cp /etc/cups/labprinters.conf /etc/cups/printers.conf" password ¬
       "root password" with administrator privileges
      do shell script "killall -9 cupsd" password ¬
       "root password" with administrator privileges
      do shell script "cupsd" password ¬
       "root password" with administrator privileges
      quit
    end tell
    
    Replace "root password" with your root password. Make sure you save your file as an Application.
  5. Go into System Preferences -> Login Items and select your application so it will launch at login.
When you login, the application and Terminal will launch, run the commands, then quit.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20031023120009550