mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
Move pkg scripts into code/tools/pkgresources
This commit is contained in:
29
code/tools/pkgresources/Scripts_app_usage/postinstall
Executable file
29
code/tools/pkgresources/Scripts_app_usage/postinstall
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
|
||||
# Run postinstall actions for root.
|
||||
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)
|
||||
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
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user