Deleting all printers

Sunday, February 23rd, 2014

As I’m building new printer installers with The Luggage (there’s a great tutorial on the Munki wiki), I’ve often come across the need to delete all installed printers first. Maybe the printers are being replaced with a different model, or maybe the existing print queues were created by hand and have subtile naming differences.

I created a script (on my GitHub repository) and have been running it as part of Apple Remote Desktop, but it should work anywhere.

Tested with: 10.6, 10.8, 10.9

Setting the Software Update Server

Sunday, January 26th, 2014

Several years ago, I submitted a post to Mac OS X Hints. At the time, I worked for an Apple authorized service provider, and wanted an easy way to switch a customer’s computer to our Software Update Server temporarily, then switch back afterwards. Two users in the Mac OS X Hints forums helped me build an AppleScript application for this purpose.

I have since made significant improvements to the script, and still use it today. The code can be found in my GitHub repository.

Tested with: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9

Customizing the login window in Mavericks

Saturday, January 25th, 2014

Before 10.9 Mavericks, customizing the login window was a sometimes complicated process. Apple has changed the resources for the login window several times over the years.

If possible, it’s generally a good idea to stay away from altering system files. However, our Windows PCs are branded, so we’d like to do the same for our Macs. With 10.9, we’ve settled upon replacing the Apple logo with our own.

We started off using this tutorial from OS X Daily – however, we found that the results weren’t consistent when replacing the Apple logo images with full-sized backgrounds as the tutorial recommends. With so many resolutions to support, we found that our custom background didn’t always cover the default gray Apple background.

Instead, after much testing, we came up with this:

  1. In the Finder, type Command-Shift-G and open /System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Resources/
  2. Make backups of these files: “apple_s1.png”, “apple_s1@2x.png”, “apple.png”, and “apple@2x.png”.
  3. Open each file in an image editor (I like Acorn), and double the size of each image.  Delete the Apple logo and replace it with a transparent version of your own.
  4. Copy your modified versions of these files back to their original folder, replacing Apple’s versions.

Log out, and you should see your logo just above the username and password fields. I have not tested against a login window using names and pictures, but it should be fine.

If Apple modifies these files in a future OS X update, you might need to replace them again. I’d recommend packaging them up for easy reinstallation.

Tested with: 10.9

Backing up VMware Fusion images

Thursday, May 16th, 2013

Traditionally, VMware Fusion has not supported using Time Machine to backup your virtual machines. Although this changed with version 4, I’d rather not enable AutoProtect. Instead, I use Carbon Copy Cloner to backup my ‘Virtual Machines’ folder to the root of my Time Machine drive.

Just one catch – if VMware Fusion is open during the copy, eventually CCC will fill up the destination drive, as it’s repeatedly copying data that’s in use. The solution? A preflight script that checks for the VMware Fusion process, and aborts the backup if the program is currently running.

The scripts are available in my GitHub repository.

Disable “Use this disk?” Time Machine prompt

Saturday, March 23rd, 2013

With a diagnostic OS, you’ll likely find yourself mounting many hard drives – either while NetBooted, or booted from an external hard drive. If Time Machine is not enabled, it will offer to backup to any reasonably-sized hard drive connected to your machine.

To disable this, run this command in the Terminal:

defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool YES

This will prevent the Time Machine prompts from appearing.

Tested with: 10.5, 10.6, 10.7, 10.8, 10.9

Testing the built-in iSight camera

Friday, March 22nd, 2013

Sometimes, when building a diagnostic OS, you need to optimize for space – you might be trying to fit the OS onto a small USB flash drive, or you want to decrease NetBoot times.

Once you’ve thrown away the obvious culprits – thanks to something like GrandPerspective – you might decide to trash the contents of /System/Library/Compositions/. I did. Unfortunately, this will break Photo Booth.

We relied on Photo Booth to test the iSight camera, so I came up with an alternative. Save this script as an application and put it in the Dock. Heck, I gave it the Photo Booth icon. It opens a new “movie recording” window in QuickTime Player, but it’s not actually recording. Good for a quick test, and faster than Photo Booth.

Tested with: 10.7, 10.8, 10.9

Enabling and configuring NFS

Sunday, January 6th, 2013

This weekend, I had a need to get NFS working on my Mac. My reasoning? I have a WDTV Live, and found that streaming video through NFS adds less overhead than using (the excellent and free) PS3 Media ServerWestern Digital’s instructions are GUI-heavy and somewhat incomplete, though, so I decided to write my own.

To configure NFS, you’ll need to create a file in /etc/exports:

sudo nano /etc/exports

If the file doesn’t already exist, it should be empty. This file contains your list of shares. Here’s an example of a share from my machine:

/Users/mike/Downloads -ro -network 192.168.1.0 -mask 255.255.255.0

Breaking it down – first, you’ve got the path to the folder you want to share. Next, it’s set so that anyone connecting has read-only access. And finally, the two last sections detail the IP range that’s allowed to access shares on your NFS server. There are many more options you can add – see this for a full listing:

man exports

Add one share per line. Once you’re happy with your exports file, all you need to do is enable NFS:

sudo nfsd enable

This will start the NFS service and keep it running, even after a reboot. You can also start and stop it on an as-needed basis:

sudo nfsd start
sudo nfsd stop

If you make changes to your exports file, you might need to restart the NFS daemon for your changes to take effect:

sudo nfsd restart

If you’d like to verify that your exports file is properly formatted, this will be useful:

nfsd checkexports

And finally, if NFS is running, you can get a listing of all of your shares (‘mounts’ in NFS terminology) via this:

showmount -e

Hope this is useful to someone! If you’d prefer a GUI anyway, NFS Manager looks to be very well done.

Tested with: 10.7, 10.8, 10.9

Disabling Spotlight

Friday, January 4th, 2013

In some cases, Spotlight’s indexing becomes a nuisance at best, and a problem at worst. A diagnostic OS can be used to repair or recover from a failing hard drive, for example, but Spotlight indexing can slow down the process (and lessen your chances of recovering data).

Luckily, it’s pretty simple to disable Spotlight. In the Terminal, run this command:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

If you later change your mind, this command will reverse it:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Note that this disables Spotlight systemwide, not just on a per-HD basis. Existing Spotlight indexes will be left untouched.

It should be noted, in OS X 10.7 and above, the App Store uses Spotlight to recognize which apps are installed and can be updated. With Spotlight disabled, the App Store will only show OS updates. If you’re updating your Diagnostic OS, I’d suggest temporarily changing this setting.

Tested with: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9

Scrolling switcher

Sunday, July 29th, 2012

Starting with 10.7 Lion, Apple switched the scrolling direction. This can cause some confusion with people used to older Mac OS versions, or people coming from a Windows background.

I wanted to see if it were possible to allow people to toggle this, so I did some digging. I found a script for trackpads on Super User, but it used GUI scripting. I tried to get something working with the CLI (so I could use “do shell script” instead), but couldn’t find anything that worked.

I also tried to detect the presence of a trackpad beforehand, but didn’t get too far with that. Though most people don’t have a mouse and a trackpad connected at the same time (and expect to use both), changing the scrolling direction applies to both – at least in 10.8.

Update: both scripts are now on GitHub.

Tested with: 10.7, 10.8

PSU MacAdmins Conference 2012 Presentation

Tuesday, June 19th, 2012

This year, I gave my first presentation at the Penn State MacAdmins Conference: Introduction to Mac Triage and Troubleshooting. Here’s the description:

In this session, we’ll go over the basics of component isolation and hardware/software troubleshooting. We’ll cover common fixes and methods for diagnosing a problem quickly and accurately.

My slides are available here, and the video is below. Enjoy!