.KEY SYS/K,QUIET/S
.BRA {
.KET }

; Install Patch Amiga OS 3.1.4.1
; ------------------------------
;
; Date: 2019-08-06
; Author: Henrik Noerfjand Stengaard
;
; AmigaDOS script to install patch Amiga OS 3.1.4.1 to Startup-Sequence.

IF "{SYS}" EQ ""
  set device "SYS"
ELSE
  set device "{SYS}"
ENDIF

; fail, if startup sequence doesn't exist
IF NOT EXISTS "$device:S/Startup-Sequence"
  echo "*e[1mError: Startup sequence doesn't exist!*e[0m"
  quit 20
ENDIF

; end, if patch amiga os 3.1.4.1 is already installed
search "$device:S/Startup-Sequence" "Patch-Amiga-OS-3141" >NIL:
IF $RC EQ 0 VAL
  IF "{QUIET}" EQ ""
    echo "Patch Amiga OS 3.1.4.1 is already installed!"
  ENDIF
  SKIP end
ENDIF

; fail, if patch amiga os 3.1.4.1 doesn't exist
IF NOT EXISTS "$device:S/Patch-Amiga-OS-3141"
  echo "*e[1mError: Patch Amiga OS 3.1.4.1 script doesn't exist!*e[0m"
  quit 20
ENDIF

; fail, if amiga os 3.1.4.1 startup doesn't exist
IF NOT EXISTS "$device:S/Amiga-OS-3141-Startup"
  echo "*e[1mError: Amiga OS 3.1.4.1 startup script doesn't exist!*e[0m"
  quit 20
ENDIF

; backup startup sequence
IF NOT EXISTS "$device:S/Startup-Sequence.3141"
  Copy >NIL: "$device:S/Startup-Sequence" "$device:S/Startup-Sequence.3141"
ENDIF

; add patch amiga os 3.1.4.1 to startup sequence
Copy >NIL: "$device:S/Amiga-OS-3141-Startup" "T:_Startup-Sequence"
Type "$device:S/Startup-Sequence" >>"T:_Startup-Sequence"
Copy >NIL: "T:_Startup-Sequence" "$device:S/Startup-Sequence"
Delete >NIL: "T:_Startup-Sequence"

; done
IF "{QUIET}" EQ ""
  echo "Patch Amiga OS 3.1.4.1 installed!"
ENDIF


; end
LAB end
