mirror of
https://github.com/munki/munki.git
synced 2026-01-06 14:40:09 -06:00
Modernize launchctl commands in app_usage pkg pre- and postinstall scripts. (Dropping support for pre-macOS 10.10)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lovingly lifted from Per Olofsson
|
||||
# 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
|
||||
@@ -10,18 +10,11 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
if [ "$3" == "/" ]; then
|
||||
|
||||
# Run postinstall actions for root.
|
||||
launchctl load /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist
|
||||
launchctl bootstrap system/ /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist
|
||||
|
||||
# Run postinstall actions for all logged in users.
|
||||
os_build_version=$(sw_vers -buildVersion | cut -b 1-2)
|
||||
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_build_version -lt 14 ]] ; 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
|
||||
for uid in $(ps -axo uid,args | grep -i "[l]oginwindow.app" | awk '{print $1}'); do
|
||||
launchctl bootstrap gui/"$uid"/ /Library/LaunchAgents/com.googlecode.munki.app_usage_monitor.plist
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lovingly lifted from Per Olofsson
|
||||
# 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
|
||||
@@ -10,18 +10,17 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
if [ "$3" == "/" ]; then
|
||||
|
||||
# Run preinstall actions for root.
|
||||
launchctl unload /Library/LaunchDaemons/com.googlecode.munki.app_usage_monitor.plist
|
||||
launchctl unload /Library/LaunchDaemons/com.googlecode.munki.appusaged.plist
|
||||
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.
|
||||
os_build_version=$(sw_vers -buildVersion | cut -b 1-2)
|
||||
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_build_version -lt 14 ]] ; 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
|
||||
for uid in $(ps -axo uid,args | grep -i "[l]oginwindow.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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user