Last active
March 1, 2025 02:14
-
-
Save timsutton/1679e37731bd06e8a05e4a85c04fdce3 to your computer and use it in GitHub Desktop.
Postinstall script to finish setting up Malwarebytes AntiMalware for Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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