Autoupdate installers in unattended mode

asked 14 Sep '11, 09:57

Jake's gravatar image

Jake ♦♦
796222226235
accept rate: 98%


Autoupdate installer can be executed in unattended mode as regular InstallBuilder installers does but depending on additional command line flags, it behavior varies:

* Regular unattended mode: autoupdate-linux.bin --mode unattended

In this mode, the autoupdate is executed as a checker. It will return a '0' exit code if it finds a new update and a positive integer otherwise. The snippet below shows how to use it from an InstallBuilder installer which bundled the autoupdate:

<project>
    ...
    <initializationActionList>
       <showQuestion default="yes" text="Would you like to check for updates?" variable="checkforupdates" />
       <actionGroup>
          <actionList>
             <!-- Once we have unpacked the bundled autoupdate and update.ini to some folder, like /tmp/autoupdate -->    
             <runProgram>
                <program>/tmp/autoupdate/autoupdate-linux.bin</program>
                <programArguments>--mode unattended</programArguments>
             </runProgram>
             <showInfo text="An update is available!">
               <ruleList>
                   <isFalse value="${program_exit_code}" />
               </ruleList>
             </showInfo>
             <showInfo text="Sorry, no update is available...">
               <ruleList>
                   <compareText text="${program_exit_code}" value="0" logic="does_not_equal" />
               </ruleList>
             </showInfo>
          </actionList>
          <ruleList>
             <compareText text="${checkforupdates}" value="yes" logic="equals" />
          </ruleList>
       </actionGroup>
    </initializationActionList>
    ...
</project>

You can find additional information about how to unpack files in this article

* Download unattended mode: autoupdate-linux.bin --mode unattended --unattendedmodebehavior download

The default unattendedmodebehavior is "check" so it can be omitted. If instead of only check for updates you want to download and install the update, the unattendedmodebehavior has to be set to "download".

As we already mentioned, a '0' return code means "An update is available" and "No update available" otherwise but in some scenarios we need more information. To provide this information, the Autoupdate uses the below summarized return codes:

* 0 : Successfully downloaded and executed the installer.
* 1 : No updates available
* 2 : Error connecting to remote server or invalid XML file
* 3 : An error occurred downloading the file
* 4 : An error occurred executing the downloaded update or evaluating its <postUpdateDownloadActionList>
* 5 : Update check disabled through check_for_updates setting

Return codes 0, 1, 2 and 5 are common for both modes while 3-4 are exclusive to 'download' mode.

When launching the Autoupdate from a Windows cmd, as it is compiled as a GUI application, it will launch it in background, reporting 0 as the exit code if the file can be executed. To force the cmd to wait for the process to finalize and retrieve the correct code returned by the Autoupdate it should be launched as:

cmd /W /C autoupdate-windows.exe --mode unattended

This is not necessary if the Autoupdate is launched from a BitRock installer using a action.

If no errors occurs in the process this will download and install the update. However, if the update is a big file you may want to show some feedback. To achieve it you can add --unattendedmodeui minimal or --unattendedmodeui minimalWithDialogs to the command line options. This will display a download progress bar as displayed in the image:

autoupdate-linux.bin --mode unattended --unattendedmodebehavior download --unattendedmodeui minimalWithDialogs

Progress bar

link

answered 14 Sep '11, 10:07

Jake's gravatar image

Jake ♦♦
796222226235
accept rate: 98%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×51
×36

Asked: 14 Sep '11, 09:57

Seen: 2,077 times

Last updated: 14 Sep '11, 10:07