Running a post-uninstall script for a Munki package

Much as I love editing text files and entering commands into Terminal.app, I do also appreciate a good GUI frontend. Apart from munkiimport, I mainly manage Munki using MunkiAdmin, as I referenced in Absolute beginner’s guide to setting up Munki (not monkey).

Of course, I got a bit too comfortable with the GUI frontend, and I put in incorrectly a post-uninstall script for a package and got back this error message: Error executing script postuninstall_script: [Errno 8] Exec format error.

After I actually read the Munki wiki page on Pre And Postinstall Scripts, I realized my mistake—I'd put in only the command I wanted without giving the environment for that command.

munkiadminpostuninstallscript
Turns out (which makes sense in hindsight) I had to put in

#!/bin/bash
before putting the actual command to run after the uninstall.

In case anyone else who's GUI-dependent (and who also hasn't read the wiki carefully) runs into this issue, that's the solution—put in the environment you're using (Is it bash, shell, python, etc.?), and not just the command itself.

1 thought on “Running a post-uninstall script for a Munki package”

Leave a Reply

Your email address will not be published. Required fields are marked *