mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
Refactor app_usage_monitor into user-level agent and privileged daemon.
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# only do this if we are installing to current startup volume
|
||||
# Lovingly lifted from Per Olofsson
|
||||
# https://github.com/MagerValp/Scripted-Mac-Package-Creation/blob/master/scripts/postinstall
|
||||
|
||||
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
|
||||
#(re-)load our LaunchDaemon
|
||||
/bin/launchctl unload /Library/LaunchDaemons/com.googlecode.munki.app_usage_monitor.plist
|
||||
/bin/launchctl load /Library/LaunchDaemons/com.googlecode.munki.app_usage_monitor.plist
|
||||
|
||||
# Run postinstall actions for root.
|
||||
launchctl load /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist
|
||||
|
||||
# Run postinstall actions for all logged in users.
|
||||
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
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user