Skip to content

Instantly share code, notes, and snippets.

@timsutton
Last active February 22, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timsutton/1679e37731bd06e8a05e4a85c04fdce3 to your computer and use it in GitHub Desktop.
Save timsutton/1679e37731bd06e8a05e4a85c04fdce3 to your computer and use it in GitHub Desktop.
Postinstall script to finish setting up Malwarebytes AntiMalware for Mac
#!/bin/sh
declare -r mbam_helper="/Applications/Malwarebytes Anti-Malware.app/Contents/Library/LaunchServices/com.malwarebytes.HelperTool"
declare -r privtools=/Library/PrivilegedHelperTools
declare -r launchd_plist=/Library/LaunchDaemons/com.malwarebytes.HelperTool.plist
# install helper tool
if [ ! -d ${privtools} ]; then
/bin/mkdir -p "${privtools}"
/bin/chmod 1755 "${privtools}"
fi
/usr/bin/install -m 0544 -o root -g wheel "${mbam_helper}" ${privtools}
# generate and load the LaunchDaemon if it doesn't already exist
if [ ! -e "${launchd_plist}" ]; then
declare -r pb=/usr/libexec/PlistBuddy
${pb} -c 'Add :Label string com.malwarebytes.HelperTool' "${launchd_plist}"
${pb} -c 'Add :MachServices dict' "${launchd_plist}"
${pb} -c 'Add :MachServices:com.malwarebytes.HelperTool bool true' "${launchd_plist}"
${pb} -c 'Add :Program string '${privtools}'/com.malwarebytes.HelperTool' "${launchd_plist}"
${pb} -c 'Add :ProgramArguments array' "${launchd_plist}"
${pb} -c 'Add :ProgramArguments:0 string '${privtools}'/com.malwarebytes.HelperTool' "${launchd_plist}"
/bin/chmod 644 "${launchd_plist}"
/usr/sbin/chown root:wheel "${launchd_plist}"
/bin/launchctl load "${launchd_plist}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment