1

I have developed a launchAgent in cocoa. It works fine for me on dev environment, by placing the plist file in location /Library/LaunchAgents/.To distribute and install this on other laptops, I created the package using package maker tool. As part of installation process I want to change permission of the plist file and copy it to /Library/LaunchAgents location. Could any one tell me how can i achieve this ?

Thanks in advance for help....Any help will be appreciated ..!!!!

Unicorn
  • 2,382
  • 6
  • 29
  • 42

1 Answers1

1

In PackageMaker, select the launchd plist, and in "Configuration" set the "Install" location to /Library/LaunchAgents/com.unicorn.omgponies.plist and the "Destination" to /. You probably don't want to enable relocation for a launchagent. Then go "Contents" and you can set the ownership and permissions there.

  • Thanks a ton. It worked for me...Can you also tell me how I can start the launchagent as soon it gets installed. Currently i need to start it manually. – Unicorn Apr 06 '10 at 09:01
  • @Unicorn: You need a postinstall script or action to invoke launchctl. –  Apr 06 '10 at 09:13
  • @Graham: I added an apple script with content &1;">, While installing the installation fails, saying post install script can not be executed. In post-install section i had given path to script, Am I missing some thing here ? – Unicorn Apr 06 '10 at 09:24
  • @Unicorn: the postinstall script needs to be a shell script, not an apple script. –  Apr 06 '10 at 10:07
  • Oh yes, I figured it out, and it worked. But to add on my problems, I see two instances of app running, one as root and another as . Did i do some thing wrong here ? – Unicorn Apr 06 '10 at 10:18
  • 2
    You don't want to enable relocation for *anything*. It should be labeled “make installation randomly fail for no good reason”. – Peter Hosey Apr 08 '10 at 07:47
  • @Peter Hosey: relocation only tends to be a problem on developer systems (which admittedly makes it an egregious problem), in my experience. –  Apr 08 '10 at 07:58
  • @Unicorn - did you ever figure out your problem? The reason that happened is that PackageMaker sudo's to root and any post-install actions automatically run as root, not the user. I'm trying to figure out how to run the script as the user. – TodK Nov 29 '10 at 13:42
  • @TodK: if the launch agent is configured to only run in graphical sessions, then a root instance should never get run, unless root logs in to the console (which is not to be recommended). –  Nov 29 '10 at 14:16
  • @Graham - problem is that launchctl load is run as root - so my plist has the assumed value of "Aqua" but runs as root. using the UserName field in the plist doesn't appear to give exactly the same rights as running launchctl load . Its an interesting problem to say the least. – TodK Nov 29 '10 at 21:41