Re: How to execute script as root, and then an another script on behalf of an ordinary user
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com 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... 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 (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Greg Neagle