Files
munki/code/pkgtemplate/Scripts_app/postinstall
T

31 lines
1.1 KiB
Bash
Executable File

#!/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