Silent update for an app?

I would like to add an option for silently updating a sandboxed OSX app (on Mavericks, but not on MAS).

I use AppWrapper to create an installer, which asks each time for a password in order to install the app.

For silent updates I found the following suggestions on the web, using Shell commands:

sudo installer -pkg your_installer_file.pkg -target /

or

echo <password> | sudo installer -pkg "your_installer_file.pkg" -target /

Both fail with this error message (tested on different Macs) :

[quote] Shell result : sudo: no tty present and no askpass program specified
[/quote]

I also tried to copy myself the newly downloaded app to the Applications folder, but replacing the old app or deleting the old app fails silently.

What would you suggest in order to enable a silent update of an app on Mavericks?

you will need to have a helper app installed to run as root to have your installer launch.

What if you app follows these steps (although I guess it won’t be “silent”)

  1. download the installer (pkg/dmg whatever) to downloads directory
  2. have app launch it (via f.launch)
  3. have app quit (installer should overwrite existing app)

The problem is you cannot update xxx.app while xxx.app is running

Thanks, David and Christian!

I have a solution, which looks somewhat creepy to me, but it works:

  1. I download the installer to a folder in SpecialFolder.ApplicationData
  2. I launch a helper console app and terminate the main application.
  3. The helper app uses an interactive shell to launch the installer (to provide sudo password):

[code] App.imInstallShell = New Shell
App.imInstallShell.Mode = 2 // Interactive

  Dim cmd As String = "sudo installer -pkg " _
  + chr(34) + App.InstallerPath + chr(34) + " -target /"
  
  If Not App.imInstallShell.IsRunning Then
    App.imInstallShell.Execute "sh"
  End If
  
  Dim pw As String = App.InstallerPW
  
  // Now start the installer
  App.imInstallShell.Write(cmd)
  App.imInstallShell.Write(Chr(13))

  // Send password      
  App.imInstallShell.Write(pw)
  App.imInstallShell.Write(Chr(13))[/code]

I have a Loop in the console’s Run event, with a App.DoEvents, where I check for install finished condition and then I launch the updated app.

On the very first run (and in user settings) I ask for the password and if the user wishes silent update, then I store the password in the keychain.

I noticed, that our users tend to not update, because they don’t like all that clicking and password entering of the standard installer.

you might be better off putting the installer in the temporary items dir just so it gets removed when / if the user logs out & logs back in or as part of normal maintenance

otherwise you’re going to need to do that for them

[quote=58659:@Norman Palardy]you might be better off putting the installer in the temporary items dir just so it gets removed when / if the user logs out & logs back in or as part of normal maintenance

otherwise you’re going to need to do that for them[/quote]
Yes, I do cleanup from my own code now. But I think your suggestion is a better idea.