New scripts for app pkg to quit and relaunch MSC.app if running

This commit is contained in:
Greg Neagle
2020-05-09 22:37:26 -07:00
parent bd570228a8
commit 8dc05e56ed
2 changed files with 43 additions and 9 deletions

View File

@@ -0,0 +1,30 @@
#!/bin/sh
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# relaunch MSC.app if it was running before we upgraded it
if [ "$3" == "/" ]; then
if [ -e /tmp/com.googlecode.munki.relaunch_msc_app ] ; then
rm /tmp/com.googlecode.munki.relaunch_msc_app
CONSOLEUSER=$(who | grep console | cut -d" " -f1)
if [ "$CONSOLEUSER" == "" ] ; then
exit 0
fi
CONSOLE_UID=$(id -u "$CONSOLEUSER")
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 [ "$uid" == "$CONSOLE_UID" ] ; then
if [[ $os_major_version -lt 10 ]] ; then
launchctl bsexec "$pid" chroot -u "$uid" / open -a "/Applications/Managed Software Center.app"
exit 0
else
launchctl asuser "$uid" open -a "/Applications/Managed Software Center.app"
exit 0
fi
fi
done
fi
fi