mirror of
https://github.com/munki/munki.git
synced 2026-01-05 22:20:00 -06:00
New scripts for app pkg to quit and relaunch MSC.app if running
This commit is contained in:
30
code/pkgtemplate/Scripts_app/postinstall
Executable file
30
code/pkgtemplate/Scripts_app/postinstall
Executable 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
|
||||
Reference in New Issue
Block a user