OS X: Run script (or app) on a post-upgrade reboot

353 views Asked by At

I'm trying to find a programmatic solution for a friend of mine, who operates a Hackintosh system, or OS X installed on non-Macintosh Intel computers. Whenever he is installing a Mac OS X security update, he needs to re-patch his audio drivers using MultiBeast. So, I was thinking about doing this automatically, given that Apple offers a way to hook a script post_upgrade (which I'm unaware of).

2

There are 2 answers

0
Sam Denty On BEST ANSWER
  1. Create a file with the following script:
#!/bin/bash

CURR_VERSION="$(sw_vers -buildVersion)"
PREV_VERSION="$(cat ~/.previous-version)"

if [ "$CURR_VERSION" != "$PREV_VERSION" ]; then
  # Do stuff here

  echo "$CURR_VERSION" > ~/.previous-version
fi
  1. chmod +x it
  2. sudo nano /Library/LaunchDaemons/version-checker.plist
  3. Type in:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>version-checker</string>
    <key>ProgramArguments</key>
    <array>
        <string>/path/to/your/check_version.sh</string>
    </array>
    <key>StartInterval</key>
    <integer>60</integer>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
  1. Save with CTRL+X, Y
  2. sudo launchctl load /Library/LaunchDaemons/version-checker.plist
1
Dup Step On

You can:

  • Sart Automator.app
  • Select "Application"
  • Click "Show library" in the toolbar (if hidden)
  • Add "Run shell script" (from the Actions/Utilities)
  • Copy&paste your script into the window
  • Test it
  • Save somewhere, for example you can make an "Applications" folder in your HOME (you will get an your_name.app)
  • Go to System Preferences -> Accounts -> Login items
  • Add this app
  • test & done