########################################################################
### MODULE:     UPGRADE
### PURPOSE:    Upgrade an instrument.
###
### Copyrights (C) 2006-2007 Applied Biosystems.  All rights reserved.
########################################################################

PUBLish Upgrade upgrade started Initializing

TRY <quote.try>
    LVAR workdir /tmp/upgrade

    PUBLish Upgrade "Validating instrument"
    IF $[ "stepone" in "$(SYST:PROD?)".lower() ] <q.supported>
        PUBLish Upgrade "Found supported instrument: $(SYST:PROD?)."
    </q.supported>
    ELSe <q.unknown>
        ERRor "Instrument class \"$(SYSTem:PRODuct?)\" is not supported by this upgrade package."
    </q.unknown>

    PUBLish Upgrade "Extracting files needed to perform upgrade"
    SYST:EXEC "mkdir -p ${workdir}; cat $(FILe:PATH? UPGRADE:upgrade-??) | tar -x -z -C${workdir} -f-"

    PUBLish Upgrade "Stopping user interface"
    SYST:EXEC "killall -q -9 aztecUI_release UpgradeSplash"

    PUBLish Upgrade "Displaying splash screen"
    SYST:EXEC "${workdir}/Splash.sh message_upgrade.png 1000000"

    PUBLish Upgrade "Installing new versions of the upgrade tools"
    SYST:EXEC "cat $(FILe:PATH? UPGRADE:install-??) | tar -x -z -C/ -f-"

    PUBLish Upgrade Cleaning up
    FILe:REMove -recursive UPGRADE:*
    PUBLish Upgrade upgrade completed.

</quote.try> <quote.catch>
    FILe:REMove -recursive UPGRADE:*
    PUBLish Upgrade upgrade aborted ${message}
</quote.catch>

