Created
April 27, 2013 20:41
-
-
Save kcrawford/5474622 to your computer and use it in GitHub Desktop.
postflight installer script to reload a LaunchAgent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# if someone is logged in | |
if who | grep -q console; then | |
# get the logged in user's uid | |
LOGGED_IN_UID=`ls -ln /dev/console | awk '{ print $3 }'` | |
# use the uid and pgrep to find the Finder process id | |
FINDER_PID=`pgrep -U ${LOGGED_IN_UID} Finder` | |
# use launchctl bsexec to run applescript code in the same Mach bootstrap namespace hierachy as the Finder | |
launchctl bsexec "${FINDER_PID}" osascript -e ' | |
tell app "Finder" | |
do shell script " | |
launchctl unload -S Aqua /Library/LaunchAgents/com.company.agent.plist | |
launchctl load -S Aqua /Library/LaunchAgents/com.company.agent.plist | |
" | |
end tell | |
' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment