; ==================================================
; ==================================================
;
; Updater v 1.6 (c) Paolo Besser 2009-2011
; A shell script that allows easy updating of AROS
; System files under Icaros. This file is meant
; for use with Icaros Desktop only
; This new release includes Live Update feature,
; thanks to Yannick Erb. Please open "livedaemon"
; script for further informations.
;
; ==================================================
; ==================================================

failat 21

; place a cookie
echo "test" >sys:test.test

; test if UpdatAROS is launched from the right volume
IF NOT EXISTS sys:test.test
  RequestChoice >ENV:Choicex Title="Error!" Body="This script must be run from*Na existing AROS installation.*Ndon't try to run it on a unvalidated volume*Nor a CD-ROM: it won't run. Click OK to exit." Gadgets=OK
  EndCli
EndIf

; remove the cookie
delete sys:test.test >NIL:

RequestChoice >ENV:Choice Title="Updater v1.6.1" Body="This program will update Icaros Desktop from a Icaros*Nupdate pack. LiveUpdater can search for updates*Non the Icaros Desktop site. Please choose what to do."  gadgets=File|Internet|Cancel
IF ${Choice} eq 1 
RequestFile >env:LUPD_ISONAME PATTERN="#?.7z" Title="Locate update file" INITIALVOLUMES
 IF NOT WARN
 setenv LUPD_TMPDIR "Downloads:LUPD"
  IF NOT EXISTS ${LUPD_TMPDIR}
  mkdir ${LUPD_TMPDIR}
  EndIF
 assign LUPD: ${LUPD_TMPDIR}
 cd LUPD:
 extras:misc/aminet/c/7zDec x ${LUPD_ISONAME}
 ; create necessary assigns
 ASSIGN sysource: LUPD:UPDATE
 ASSIGN sydest: SYS:
 cd ${EXTRASPATH}//
 cd >env:OTHDEST
 ASSIGN othdest: "${OTHDEST}"
 delete env:OTHDEST >NIL:
 setenv LUPD_TODO "continue"
 cd sys:tools/LUPD
 execute copyfiles
 execute livecleaner
 EndIf
EndIF
IF ${Choice} eq 2 
 execute livedaemon
 execute copyfiles
 execute livecleaner
EndIf
IF ${Choice} eq 0
 delete env:Choice
 EndCli
EndIf

IF ${LUPD_TODO} eq "continue"
RequestChoice >ENV:Choice Title="Updating completed" Body="In order to let new system files work*nproperly, YOU MUST REMOVE NIGHTLY ISO*nFROM DRIVE, then reboot the machine*n*nPlease remove ISO or CD from drive*nand select an option to continue." Gadgets=Reboot|Later
IF ${Choice} eq 1
  reboot
EndIf
unsetenv LUPD_TODO
EndIf
unsetenv LUPD_TODO
