#!/bin/sh # Lovingly adapted from Per Olofsson # https://github.com/MagerValp/Scripted-Mac-Package-Creation/blob/master/scripts/postinstall export PATH=/usr/bin:/bin:/usr/sbin:/sbin # Execute preinstall actions if we're installing on a live system. # This is useful for unloading launch daemons and agents. if [ "$3" = "/" ]; then # Run preinstall actions for root. if launchctl print system/munki.app_usage_monitor > /dev/null 2>&1 ; then launchctl bootout system/munki.app_usage_monitor fi if launchctl print system/com.googlecode.munki.appusaged. > /dev/null 2>&1 ; then launchctl bootout system/com.googlecode.munki.appusaged fi # Run preinstall actions for all logged in users. for uid in $(ps -axo uid,args | grep "/[F]inder.app/" | awk '{print $1}'); do if launchctl print gui/"$uid"/com.googlecode.munki.app_usage_monitor > /dev/null 2>&1 ; then launchctl bootout gui/"$uid"/com.googlecode.munki.app_usage_monitor fi done fi exit 0