RE: Launch a System Agent from an Installer script
RE: Launch a System Agent from an Installer script
- Subject: RE: Launch a System Agent from an Installer script
- From: Xochitl Lunde <email@hidden>
- Date: Tue, 13 Dec 2011 16:29:06 +0000
- Thread-topic: Launch a System Agent from an Installer script
I believe I handle these issues in the PowerAlertSA installer for Mac. Maybe I didn't do everything or anything perfectly, but I do address all of the cases that you are talking about. PowerAlert has a system daemon and a user agent, as well as a Java UI, so I think the installation scripts in PowerAlert could help you out:
http://www.tripplite.com/en/products/poweralert-software.cfm
As far as I know, you should be able to right click on the package inside the DMG and choose "Show Package Contents". Then inside of Contents/Resources you can see how I coded the InstallationCheck script as well as the preinstall, postinstall, etc. (Open with -> Xcode.app) I believe you can look at any package like this and compare similar software installation scripts to what you are doing if the scripts are not compiled.
Basically, I don't let the product install if more than one user is logged in. Then I handle stopping the agent and daemons before upgrading. I tested these scripts a lot using Leopard and Snow Leopard, including using ARD with no users logged in. I have tested the installer on Lion, but not with ARD. (On Lion it errors sort of uninformatively if Java is not installed but otherwise the installation is fine. ._. )
Another thing you have to handle is the command line install. If the user has to authenticate, then he will be installing your package using sudo on the command line - and you only get the SUDO_USER environment variable in one of the early scripts (InstallationCheck?). These scripts should handle that as well.
You can use 'su' to change users so that you can start your user agent as that user. If you look at the PowerAlert scripts, the agent which is the user agent is called PowerAlertUserNotify, so you'll want to look at its behavior the most. The '|| :' at the end of the 'su' lines is a trick from this list to make 'su' not hang. You'll see that I had to do quite a bit of extra work to figure out what user to start the agent for.
One thing that can really help you determine what is going on during debugging is to have your scripts write their environment variables and any other info to a file (not for release of course). You can then open the file and see what the heck environment variables you are really getting when doing ARD installs, command line installs, GUI installs, etc. I was surprised to see what a variety of environment variables my scripts would get during 1 install.
Hope this helps.
X.
________________________________________
From: installer-dev-bounces+xochitl_lunde=email@hidden [installer-dev-bounces+xochitl_lunde=email@hidden] on behalf of Colin Cornaby [email@hidden]
Sent: Sunday, December 11, 2011 4:00 AM
To: Installer-Dev mailing-list
Subject: Re: Launch a System Agent from an Installer script
Be careful here, because you can make the sort of mistakes that drove me insane when I worked in IT and had to use these installers.
Keep in mind that if the application is installed via remote desktop no user at all is logged in, and I may have pushed the installer to the machine as an entirely different user that could even be a network account.
Sent from my iPhone
On Dec 10, 2011, at 10:18 PM, Eli Bach2 <email@hidden> wrote:
>
> On Dec 10, 2011, at 10:45 PM, Nick wrote:
>
>> The systems are Snow Leopard and Lion, it also would be great if I
>> could do that on Leopard.
>
> What do you expect to happen if:
>
> -more than one user is logged in
> -nobody is logged in
> -your agent is already running in any/all user contexts
>
> Eli
>
> _______________________________________________
> 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
_______________________________________________
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
_______________________________________________
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