Disabling Automatic Updates on Mountain Lion

Here’s another “just so I don’t forget” script for OS X. This performs two tasks:

  1. Turn off auto updates
  2. Point Software Update to a custom SUS URL (I’m using reposado, but it should also apply to an Apple SUS).

The script supports OS X 10.6 (Snow Leopard) through 10.8 (Mountain Lion).

Why disable auto updates if we’re also setting the CatalogURL to our own managed software update server? Well, in my case it’s because I’m using Munki to deploy software and settings. You can configure Munki to check for Apple updates as well as your custom installers, but it doesn’t do so out of the box. That works out great for me because I want to make sure I keep my faculty and staff machines patched and updated, but I don’t want to muck with teaching spaces (labs, e-classrooms, research machines, etc) during a time when they can’t afford downtime. Hence:

#!/bin/bash

#
#----You'll need to edit this to match your SUS URL----
#
SUS="http://reposado.example.com"

# Plist locations
PLIST=/Library/Preferences/com.apple.SoftwareUpdate

# Catalogs
ML_CATALOG="${SUS}/content/catalogs/others/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog"
LION_CATALOG="${SUS}/content/catalogs/others/index-lion-snowleopard-leopard.merged-1.sucatalog"
SLEO_CATALOG="${SUS}/content/catalogs/others/index-leopard-snowleopard.merged-1.sucatalog"

# Get the system version
version=$(/usr/bin/defaults read /System/Library/CoreServices/SystemVersion ProductVersion | sed 's/^[^.]*\.//' | sed 's/\.[^.]$//')

# Turn off automatic updates
/usr/sbin/softwareupdate --schedule off

# MOUNTAIN LION
if [ $version == 8 ]; then
  /usr/bin/defaults write "${PLIST}" CatalogURL "${ML_CATALOG}"

# LION
elif [ $version == 7 ]; then
  /usr/bin/defaults write "${PLIST}" CatalogURL "${LION_CATALOG}"

# SNOW LEOPARD
elif [ $version == 6 ]; then
  /usr/bin/defaults write "${PLIST}" CatalogURL "${SLEO_CATALOG}"
fi
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s