views:

440

answers:

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 ..!!!!

+1  A: 

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.

Graham Lee
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
@Unicorn: You need a postinstall script or action to invoke launchctl.
Graham Lee
@Graham: I added an apple script with content <do shell script "launchctl load /Library/LaunchAgents/LaunchAgent.plist 2>">, 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
@Unicorn: the postinstall script needs to be a shell script, not an apple script.
Graham Lee
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 <user>. Did i do some thing wrong here ?
Unicorn
You don't want to enable relocation for *anything*. It should be labeled “make installation randomly fail for no good reason”.
Peter Hosey
@Peter Hosey: relocation only tends to be a problem on developer systems (which admittedly makes it an egregious problem), in my experience.
Graham Lee