Re: [launchd-dev] Loading LaunchAgents for users in postinstall
As this solution (launchctl bsexec chroot) finally started working only in 10.10 and was broken almost till final, release version of Yosemete I suggest you to wait for the final release and file a bug report to apple. Hopefully they will fix it ASAP. ——————————————————— Hofi – Istvan Hoffmann On 7/17/15, 17:11 , "Per Olofsson" <launchd-dev-bounces@lists.macosforge.org on behalf of per.olofsson@gu.se> wrote:
When an installer package contains a LaunchAgent we typically try to load it into any current user sessions, to avoid requiring a logout or restart. Through trial and error we've arrived at using launchctl bsexec with chroot in a loop like this:
if [[ "$3" == "/" ]]; then # Load agent for all logged in users. 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" -ne 0 ]]; then launchctl bsexec "$pid" chroot -u "$uid" / launchctl unload "$AGENT" launchctl bsexec "$pid" chroot -u "$uid" / launchctl load "$AGENT" fi done fi
It's not perfect but it got the job done, but it looks like it breaks in the 10.11 betas if SIP is enabled (launchctl exits with code 5). Is there a better/proper/supported way of loading LaunchAgents for users in a background script running as root?
-- Per Olofsson, IT-service, University of Gothenburg
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org https://lists.macosforge.org/mailman/listinfo/launchd-dev
17 juli 2015 kl. 21:55 skrev Hofi <hofione@gmail.com>:
As this solution (launchctl bsexec chroot) finally started working only in 10.10 and was broken almost till final, release version of Yosemete I suggest you to wait for the final release and file a bug report to apple. Hopefully they will fix it ASAP.
I'm not sure what you mean, we have been using it in production since at least 10.7. -- Per Olofsson, IT-service, University of Gothenburg
I mean it was broken for a while in 10.10 pre release versions, but fortunately it fixed for the final version, may be this time the same will happen On Jul 18, 2015 10:24 AM, "Per Olofsson" <per.olofsson@gu.se> wrote:
17 juli 2015 kl. 21:55 skrev Hofi <hofione@gmail.com>:
As this solution (launchctl bsexec chroot) finally started working only
in 10.10 and was broken almost till final, release version of Yosemete I suggest you to wait for the final release and file a bug report to apple.
Hopefully they will fix it ASAP.
I'm not sure what you mean, we have been using it in production since at least 10.7.
-- Per Olofsson, IT-service, University of Gothenburg
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org https://lists.macosforge.org/mailman/listinfo/launchd-dev
participants (3)
-
Hofi
-
Per Olofsson
-
Tunyacsap Hofi