Re: How to execute script as root, and then an another script on behalf of an ordinary user
Re: How to execute script as root, and then an another script on behalf of an ordinary user
- Subject: Re: How to execute script as root, and then an another script on behalf of an ordinary user
- From: Greg Neagle <email@hidden>
- Date: Tue, 4 Jan 2011 16:37:54 -0800
On Jan 4, 2011, at 4:00 PM, eveningnick eveningnick wrote:
> hello
> I have faced with a problem needing to execute 2 actions after
> installation (i placed them as postinstall scripts).
> Firstly, i need to install plist files into /Library/LaunchDaemons and
> /Library/LaunchAgents
Why aren't these simply part of the package payload?
> (this can be done only from "root" script)
> And then i need to start a daemon and an agent using launchctl
>
> The problem is that while daemon can be started (because post
> installation script is running as root, i can execute launchctl load
> -w /Library/LaunchDaemons/com.mydaemon), i can't start an agent. Agent
> needs to be loaded and started by a user, not by a root - if a user
> executes a command "sudo launchctl load -w
> /Library/LaunchAgents/com.myagent", this agent will be loaded into
> system domain - i.e. by a global launchd instance while i need to load
> it using a per-session launchd instance.
This is difficult to do correctly in all instances. See http://stackoverflow.com/questions/1106638/starting-stopping-a-launchd-agent-for-all-users-with-gui-sessions
It may be easier to simply require a logout (or a reboot) after install; when the user logs back in the LaunchDaemon will be loaded.
-Greg _______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden