Advice on installing an Agent to the users home directory
Advice on installing an Agent to the users home directory
- Subject: Advice on installing an Agent to the users home directory
- From: Citizen <email@hidden>
- Date: Wed, 26 Aug 2009 13:25:52 +0100
Hello,
My new application includes a User Agent. I want to give the user the
option to install this application in the system domain or the user
domain. My second requirement was that the installer launches the
Agent without a system restart or logout.
My problem is, that I don't know how to get the Installer to
appropriately set up the Agent's Property List in the User Domain.
I was hoping that there was someone on this list that had already
achieved this, and give some pointers on if I'm taking the right
approach or not. I'm new to Install topics and Unix scripting.
Here's what I'm doing...
I'm using PackageMaker 3 and targeting OS X 10.5 (Leopard) and later.
* Currently I'm installing the Application and the Agent in the
Application directory of the relevant domain.
* The Agent Property List "com.zenopolis.ApplicationAgent.plist" is as
follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd
">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zenopolis.ApplicationAgent</string>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/Name/Desktop/stderror.txt</string>
<key>StandardOutPath</key>
<string>/Users/Name/Desktop/stdout.txt</string>
<key>ProgramArguments</key>
<array>
<string>-ROOTPREFIX-/Applications/ApplicationAgent.app/Contents/
MacOS/ApplicationAgent</string>
</array>
</dict>
</plist>
* The Agent Property List is being placed in the Library/LaunchAgents
directory of the relevant domain.
* The Agent Property List file permissions are set to root/wheel and
644 in the installer.
* To replace the -ROOTPREFIX- string (and launch the Agent) I use the
following script:
#!/usr/bin/env bash
echo $SCRIPT_NAME: launching ApplicationAgent
if test -e ~/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist; then
perl -pi -e 's/-ROOTPREFIX-/$HOME/' ~/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist
chown root:wheel ~/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist
chmod 644 ~/Library/LaunchAgents/com.zenopolis.ApplicationAgent.plist
launchctl load ~/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist
elif test -e /Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist; then
perl -pi -e 's/-ROOTPREFIX-//' /Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist
launchctl load /Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist
fi
exit 0
* For the User Domain, the perl command does not work. The result for
this is the path "/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist". What I was attempting to get
was the path "/Users/username/Library/LaunchAgents/
com.zenopolis.ApplicationAgent.plist".
Is this general approach correct? Do I just need to keep searching and
work out the right scripting voodoo? Or is this likely to be a dead
end anyway? Are any of you tackling this same requirements in a
completely different way?
The following two attempts lead me to believe that I needed to set an
absolute path in the Application Agent Property List:
* I've tried replacing -ROOTPREFIX- for the User Domain with "~". The
console showed the error: posix_spawnp("~/Applications/
ApplicationAgent.app/Contents/MacOS/ApplicationAgent", ...): No such
file or directory.
* I've also tried making the ProgramArguments value in the Agent
Property List a relative path (../../Applications/ApplicationAgent.app/
Contents/MacOS/ApplicationAgent), but this did not work in the User
Domain. The console showed the error: posix_spawnp("../../Applications/
ApplicationAgent.app/Contents/MacOS/ApplicationAgent", ...): No such
file or directory.
Regards,
Dave
------
David Kennedy (http://www.zenopolis.com)
_______________________________________________
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