Maintenance CD Overview

By: Scott Doenges - Revised: 2006-06-08 devin

The download also includes a "Run Server Maintenance" script, which has the added feature of defragmenting drives using PlusOptimizer 1.3.

Introduction

The purpose of this automated Maintenance CD is to speed up the process of running routine maintenance on an entire Lab full of Macs. We now support over 400 Macs campuswide, so the less time we have to spend individually running maintenance utilities on these machines, the better.

The idea is that we could stick a Maintenance CD into each computer in a Lab, and it would automatically run routine maintenance (i.e. update hard disk driver, rebuild directory, delete/rebuild desktop database, and de-fragment drive) and within 10-15 minutes the entire Lab would be finished, whereas manually running each machine in a Lab would take much longer. So basically, the main motivation here was laziness. Oh, and to save time by spending hours upon hours writing and debugging the AppleScript that would do all of this for us.


Why perform routine maintenance?

Why do we bother running routine maintenance on so many machines?

Over time and with excessive use, lab machines' hard drives can get fragmented, their disk directories can get fouled up, and their desktop databases can get corrupted. Running maintenance utilities on the hard drives can fix these problems. Below is an explanation of what gets fixed by each utility we use on the Maintenance CD:
  • Hard Disk Driver
     
    • What is the Hard Disk driver?

      This driver is what allows your computer to talk to your hard drive. Updating this driver fixes bugs with previous drivers, making your computer communicate more effectively with your hard drive.

      We use Apple's "Drive Setup" utility to update disk drivers. This software is freeware and comes with all Mac OS installation CDs, or it can be downloaded here.

      (Note that we hacked our copy of Drive Setup to fit our needs on this project - we added a keyboard command to the Update Driver command using ResEdit. The keyboard command is then simulated by the "Sändi's Additions" scripting addition.)
       
  • Disk Directory
     
    • What is the Disk Directory?

      The disk directory is the area of a disk used by the Mac OS to "map" all of the information stored on the disk. Some of what is stored in the directory includes numbers, names, locations, types, and sizes of files and folders saved on the disk. If your disk's directory gets corrupted (which can be caused if your computer crashes while writing to the directory, for example), rebuilding the directory is the best thing to do.

      We use Alsoft's "DiskWarrior 2.0" to rebuild directories. In our experience this is by far the best utility for this purpose. We ran into serious problems using Diskwarrior 2.1 with this script - 2.1 actually damages the boot blocks of any disk it runs on when run via AppleScript, which requires a manual Diskwarrior run to repair. Diskwarrior 2.0 does not do this, so DO NOT update your Maintenance CD to use 2.1. Alsoft is aware of the problem (but don't seem very concerned about it). For more information on DiskWarrior, click here. Note that Diskwarrior is a commercial product.
       
  • Desktop Databases
     
    • What are the Desktop Databases?

      Data stored in the Desktop databases includes file-to-parent application information, as well as file and appliction icons, type and creator codes, file comments, and semi-critical disk directory information. You can tell when your databases need deleting/rebuilding when file icons appear as generic icons, or when Finder operations are slow and quirky.

      We use a freeware utility called "Trash•Desktop 1.2.1" to rebuild the desktop databases. It can be downloaded here.

CD Setup

We set up this CD by first installing a Universal System Folder (see below) onto a Jaz disk, then copying all of the utilities onto the Jaz. The reason for this was so that we wouldn't have to keep re-burning CDs to make sure the image worked. We then booted a G3 off of the Jaz disk, and since it was a read/write volume, we were able to fine-tune the image (i.e. Desktop pic, System Prefs, etc.), and begin working on the actual AppleScript that would automate the maintenance procedures. Once we got the AppleScript working, we locked the Jaz disk and made sure that the script and utilities wold run properly off of a locked volume, then burned the contents of the Jaz onto a CD-R.

A Universal System folder is a system folder that is not hardware-specific (i.e., it will work on any disk it is installed onto, regardless of hardware setup). This allows the Maintenance CD to work on any Mac we put the CD into.

The AppleScript

We used multiple Scripting Additions and applications to make this script work the way we wanted it to. Below is a list of additional components used:

Okey Dokey Pro
This control panel watches for dialog boxes and selects the default button for you. It allows you to set it so it only does this in certain applications, so we set it to hit "OK" in Drive Setup after the driver has been updated, and in Diskwarrior after the replacement directory has been constructed. Click here to download Okey Dokey Pro. (link dead)

Appearance OSAX
This scripting addition allowed us to create detailed feedback windows that let the user know which maintenance function the script is currently performing. For more info or to download an evalution, click here. (link dead)

Jon's Commands
This scripting addition provides many useful functions, including more flexible methods of copying, moving, and deleting files than Apple's standard methods. Click here to download this addition.

Sändi's Additions
We used this to simulate mouse clicks and keyboard commands for the Drive Setup portion of the script. Click here to download this addition. (link dead)

How it works

We created an alias on the desktop of the Maintenance CD, so that when you walk up to a Mac and put the CD in, you just need to click the "Set Startup Disk to CD/Restart" alias, and it runs an AppleScript that does just that. The script saves a SimpleText file containing the name of the original Startup Disk onto the Hard Drive. This is so that when the Maintenance is finished running, it can set the Startup Disk back to the appropriate volume.

The computer then restarts, and boots up off the CD. We set the desktop pattern to a hideous yellow so it's easy to tell which computers in a Lab are running the CD. We also created an "Out of Order" desktop pic that will hopefully keep people from using the computers while they are running the scripts.

"Do you want to run routine maintenance?" dialog box
You have 30 seconds to click "Yes" or "No", after which the Script automatically selects "Yes" and begins maintenance. We also added dialog boxes to let us know which operation it is currently performing (the yellow dialog boxes shown below).


Set Original Startup Disk
It first sets the Startup Disk back to the orignal, based on the contents of the "startupDiskName" file on the desktop of the Hard Disk.

Update Hard Disk Driver
It opens Drive Setup, and updates the disk drivers for the startup volume.


Rebuild Directory
It then runs DiskWarrior on whichever volumes are a) non-ejectable and b) local:


Delete/Rebuild Desktop Database
Then it deletes the Desktop DB files for the original Startup disk.

The script then copies an additional script into the original startup drive's Startup Items folder that will a) eject the CD on startup and b) run RevRdist on the machine. It then restarts the computer. All of this will take between 3 and 10 minutes, depending on the speed of the machine and the severity of the drive problems (although if you add the defragment function to the script, . After rebooting, the CD will eject and RevRdist will launch.