diff --git a/code/pkgtemplate/Scripts_app_usage/postinstall b/code/pkgtemplate/Scripts_app_usage/postinstall index efa03316..a9a1faaa 100755 --- a/code/pkgtemplate/Scripts_app_usage/postinstall +++ b/code/pkgtemplate/Scripts_app_usage/postinstall @@ -5,6 +5,7 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin + # Execute postinstall actions if we're installing on a live system. # This is useful for loading launch daemons and agents. if [ "$3" == "/" ]; then @@ -13,10 +14,15 @@ if [ "$3" == "/" ]; then launchctl load /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist # Run postinstall actions for all logged in users. + os_major_version=$(sw_vers -productVersion | cut -d. -f2) for pid_uid in $(ps -axo pid,uid,args | grep -i "[l]oginwindow.app" | awk '{print $1 "," $2}'); do pid=$(echo $pid_uid | cut -d, -f1) uid=$(echo $pid_uid | cut -d, -f2) - launchctl bsexec "$pid" chroot -u "$uid" / launchctl load /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + if [[ $os_major_version -lt 10 ]] ; then + launchctl bsexec "$pid" chroot -u "$uid" / launchctl load /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + else + launchctl asuser "$uid" launchctl load /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + fi done fi diff --git a/code/pkgtemplate/Scripts_app_usage/preinstall b/code/pkgtemplate/Scripts_app_usage/preinstall index e0ce938e..e75f1e12 100755 --- a/code/pkgtemplate/Scripts_app_usage/preinstall +++ b/code/pkgtemplate/Scripts_app_usage/preinstall @@ -14,10 +14,15 @@ if [ "$3" == "/" ]; then launchctl unload /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist # Run preinstall actions for all logged in users. + os_major_version=$(sw_vers -productVersion | cut -d. -f2) for pid_uid in $(ps -axo pid,uid,args | grep -i "[l]oginwindow.app" | awk '{print $1 "," $2}'); do pid=$(echo $pid_uid | cut -d, -f1) uid=$(echo $pid_uid | cut -d, -f2) - launchctl bsexec "$pid" chroot -u "$uid" / launchctl unload /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + if [[ $os_major_version -lt 10 ]] ; then + launchctl bsexec "$pid" chroot -u "$uid" / launchctl unload /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + else + launchctl asuser "$uid" launchctl unload /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist + fi done fi