.key test/s,full/s
.bra [
.ket ]
;
echo "*Ec*N                   2.0 Installation/Update*N"
;
; Must have 2.0 roms for this script to work
version >NIL: 37
if warn
echo "You must be using 2.0 Kickstart to install the 2.0 Workbench !"
skip end
endif
;
; make required commands resident
;
echo "*NSetting up commands..."
;
resident c:Copy pure
resident c:Assign pure
resident c:Info pure
resident c:Rename pure
resident c:Delete pure
resident c:List pure
resident c:Makedir pure
resident c:Execute pure
resident c:Eval pure
resident >NIL: c:IconPos pure
;
; set directory to return to
assign tempdir: ""
cd ram:
; make sure they booted from the install disk
set target `2.0Install:c/list sys:system.info lformat="%f"`
if "$target" NOT EQ "2.0Install:"
    echo "Please boot from your 2.0Install disk to install the 2.0 software."
    if "[test]" EQ ""
        skip exit
    endif
endif
;
failat 21
;
; attempt to figure out the name of sys: partition
;
; is it an A3000 style set up ?
assign >NIL: exists wb_2.x:
if not warn
; Get the volume name of the wb_2.x: device
    ; the .info will be deleted later with the rest of them
    echo "findme" >wb_2.x:.info
    set target `list wb_2.x:.info lformat="%f"`
else
; is it a 2091 or A590 ?
assign >NIL: exists Workbench:
if not warn
set target Workbench:
else
; is it a 2090a ?
assign >NIL: exists BOOT:
if not warn
    set target fh0:
    ; see if they have the standard mounts
    if exists BOOT:devs/MountList.HD
        mount fh0: from BOOT:devs/MountList.HD
        mount fh1: from BOOT:devs/MountList.HD
    else
        mount fh0: from BOOT:devs/MountList
        mount fh1: from BOOT:devs/MountList
    endif
else
; is it a 2090 SCSI ?
assign >NIL: exists dh2:
if not warn
set target dh2:
else
; is it a 2090 ST506 ?
assign >NIL: exists dh0:
if not warn
set target dh0:
endif
endif
endif
endif
endif
;
; If we can't tell what kind of system it is, ask the user directly.
; Note that we must remember to ask for a keymap afterwords.
if "$target" EQ "2.0Install:"
    set needSKeymap 1
    skip nameloop
endif

; make them pick a keymap so they can answer the questions.
;
if "${sys/keyboard}" EQ "*${sys/keyboard}"
    echo "*NPlease select a default keymap."
    execute Picky $target
endif
;
; make sure we got it right
Ask "*NIs your normal SYS: partition located on $target ? (Y/N) "
if not warn
lab nameloop
  echo "Type the name of your Workbench (SYS:) partition (Q to quit) ? " noline
  set >NIL: target ?
; Test to see if they gave a reasonable response
  if "$target" EQ "Q"
      skip exit
  endif

; first add a ":" if they forgot

  if "`echo $target len 1`" NOT EQ ":"
    set target $target:
  endif

  if "${target}" EQ "SYS:"
    echo "Error:  cannot install to the 2.0Install disk."
    echo "Please give the volume name of your SYS: partition.*N"
    skip back nameloop
  endif

  assign >NIL: exists "${target}"
  if warn
    echo "Error: partition does not exist.  The partition may not"
    echo "be mounted, or the driver for your card may not have"
    echo "been started.  If this is the case, you will need to"
    echo "copy the driver into the Expansion drawer of this disk,"
    echo "or perform the mount by hand before starting this Install.*N"
    skip back nameloop
  endif
  ;
  ; if full flag is set, we don't check for startup-sequence
  ; as we are assuming the partition is formatted.
  ;
  if "[full]" EQ ""
    if not exists "${target}s/Startup-Sequence"
      echo "Warning: There is no startup-sequence on this partition."
      ask "Continue anyway ? (Y/N) "
      if warn
	skip partok
      endif
      echo "Please try again.*N"
      skip back nameloop
    endif
  endif
endif

lab partok

; if the user had to explicitly specify a target partition,
; then give him a second chance to choose a keymap.
if $needSKeymap EQ "1"
    if "${sys/keyboard}" EQ "*${sys/keyboard}"
        echo "*NPlease select a default keymap."
        execute Picky $target
    endif
endif

if "${sys/keyboard}" NOT EQ "*${sys/keyboard}"
    makedir >NIL: ${target}prefs
    makedir >NIL: ${target}prefs/env-archive
    makedir >NIL: ${target}prefs/env-archive/sys
    echo >${target}prefs/env-archive/sys/keyboard ${sys/keyboard}
endif


; make sure the date on their system is reasonable.
resident >NIL: c:date force
echo "*NSystem date is `date`."
Ask "Is this correct ? (Y/N) "
if not warn
    echo "Please enter correct date (DD-MMM-YY): " noline
    date >NIL: ?
    echo "Please enter correct time (HH:MM): " noline
    date >NIL: ?
    setclock save
    echo "System date set to `date`."
endif
resident remove date

;
;aliases for testing
;
if "[test]" NOT EQ ""
    echo "In test mode"
    alias copy echo "-> copy"
    alias delete echo "-> delete"
    alias iconpos echo "-> iconpos"
    alias rename echo "-> rename"
endif
;
; make some source assignments for convenience
;
assign a: 2.0Install:
assign target: "${target}"
;
; Little script that only deletes files that exist -- avoids unneeded warnings
copy a:s/RoomForFonts a:s/DelExist RAM: quiet
;

echo "*EcThis procedure will update your hard disk with a new version of 2.0."
echo "Commands on your current SYS: partition will be overwritten."
echo "Obsolete commands will be deleted. (But your startup-sequence,"
echo "StartupII and mountlist will be saved.)*N"
Ask "Do you wish to continue ? (Y/N) "
if not warn
echo "Installation process stopped."
skip exit
endif
;
;
; Create a place for the old commands
echo "*NNow creating a ${target}OLD directory for old commands and scripts..."
if exists target:OLD
    set newname `date`
    set newname `echo "$newname" len 18`
    set newname OLD_`echo "$newname" first 1 len 9`
    echo "*NWARNING: ${target}OLD already exists.  This directory"
    echo "will be renamed to *"$newname*" and a new OLD created."
    rename >NIL: target:OLD "target:${newname}"
endif
    makedir >NIL: target:OLD

; For storing Preferences
;
makedir >NIL: target:prefs/env-archive
makedir >NIL: target:prefs/env-archive/sys
;
ASSIGN >NIL: exists boot:
if not WARN
; its a 2090a
    makedir >NIL: BOOT:OLD
    rename >NIL: BOOT:s/Startup-Sequence BOOT:OLD
    copy a:s/S-S_boot BOOT:s/Startup-Sequence 
endif
;
echo "*NMoving your Startup-Sequence and Mountlist into ${target}OLD."
rename >NIL: target:s/Startup-Sequence target:devs/MountList target:OLD quiet
if exists target:s/Shell-Startup
echo "Moving your s:Shell-Startup into ${target}OLD."
rename >NIL: target:s/Shell-Startup target:Old quiet
endif
if exists target:s/CLI-Startup
echo "Moving your s:CLI-Startup into ${target}OLD."
rename >NIL: target:s/CLI-Startup target:Old quiet
endif
if exists target:s/StartupII
echo "Moving your s:StartupII into ${target}OLD."
rename >NIL: target:s/StartupII target:Old quiet
endif
if exists target:s/BRUTab
echo "Moving your s:BRUTab into ${target}OLD."
rename >NIL: target:s/BRUTab target:Old quiet
endif
if exists target:s/HDBackup.config
echo "Moving your s:HDBackup.config into ${target}OLD."
rename >NIL: target:s/HDBackup.config target:Old quiet
endif
if exists target:s/ed-startup
echo "Moving your s:ed-startup into ${target}OLD."
rename >NIL: target:s/ed-startup target:Old quiet
endif
if exists target:devs/system-configuration
echo "Moving your devs:system-configuration into ${target}OLD."
rename >NIL: target:devs/system-configuration target:Old quiet
endif
if exists target:l/pipe-handler
echo "Moving your l:pipe-handler into ${target}OLD."
rename >NIL: target:l/pipe-handler target:Old quiet
endif
;
; Now to install the software
;

; save off their wbconfig if it exists
if exists target:prefs/env-archive/sys/wbconfig.prefs
    copy target:prefs/env-archive/sys/wbconfig.prefs ram: quiet
endif

;
; lets see about making some room
;
cd ram:
;
; Rename or delete obsolete files or old files that are now in new places
;
echo "*NLooking for files in ${target}C that are obsolete under 2.0..."
;
ram:DelExist target:c/setenv
ram:DelExist target:c/getenv
ram:DelExist target:c/echo
ram:DelExist target:c/path
ram:DelExist target:c/resident
ram:DelExist target:c/ask
ram:DelExist target:c/CD
ram:DelExist target:c/else
ram:DelExist target:c/endcli
ram:DelExist target:c/endif
ram:DelExist target:c/endskip
ram:DelExist target:c/failat
ram:DelExist target:c/fault
ram:DelExist target:c/if
ram:DelExist target:c/lab
ram:DelExist target:c/newcli
ram:DelExist target:c/newshell
ram:DelExist target:c/prompt
ram:DelExist target:c/quit
ram:DelExist target:c/run
ram:DelExist target:c/skip
ram:DelExist target:c/stack
ram:DelExist target:c/why
echo "."
;
; delete the old commodities
;
if exists target:Tools/blanker
    echo "Looking for old commodities from ${target}Tools..."
endif
ram:DelExist target:Tools/blanker
ram:DelExist target:Tools/fkey
ram:DelExist target:Tools/ihelp
ram:DelExist target:Tools/nocapslock
ram:DelExist target:Tools/autopoint
ram:DelExist target:Tools/blanker.info
ram:DelExist target:Tools/fkey.info
ram:DelExist target:Tools/ihelp.info
ram:DelExist target:Tools/nocapslock.info
ram:DelExist target:Tools/autopoint.info
echo "."

echo "Looking for obsolete system libraries..."
ram:DelExist target:libs/icon.library
ram:DelExist target:libs/info.library
ram:DelExist target:devs/ramdrive.device
ram:DelExist target:devs/keymaps/usa1
ram:DelExist target:l/Disk-Validator
ram:DelExist target:l/Newcon-Handler
ram:DelExist target:l/Shell-Seg
ram:DelExist target:l/Ram-Handler
echo "."

echo "Looking for tools that have been replaced under 2.0..."
ram:DelExist target:Prefs/CopyPrefs
ram:DelExist target:Prefs/CopyPrefs.info

ram:DelExist target:Tools/KeyToy
ram:DelExist target:Tools/KeyToy.info
ram:DelExist target:Tools/KeyToy2000
ram:DelExist target:Tools/KeyToy2000.info
ram:DelExist target:Tools/Palette
ram:DelExist target:Tools/Palette.info
ram:DelExist target:Tools/IconMerge
ram:DelExist target:Tools/IconMerge.info
;
ram:DelExist target:System/FastMemFirst
ram:DelExist target:System/FastMemFirst.info
ram:DelExist target:System/InitPrinter
ram:DelExist target:System/InitPrinter.info
;
ram:DelExist target:Utilities/Calculator
ram:DelExist target:Utilities/Calculator.info
ram:DelExist target:Utilities/ClockPtr
ram:DelExist target:Utilities/ClockPtr.info
ram:DelExist target:Utilities/CMD
ram:DelExist target:Utilities/Cmd.info
ram:DelExist target:Utilities/GraphicDump
ram:DelExist target:Utilities/GraphicDump.info
ram:DelExist target:Utilities/PrintFiles
ram:DelExist target:Utilities/PrintFiles.info
echo "."
;
echo "*NAdjusting positions of icons on your SYS: partition..."
;
; Delete all ".info" files
;
list target:#? all files pat=.info lformat "delete *"%p%n*" quiet" >t:dinfo
execute t:dinfo
delete ram:delexist quiet
;
; make all icons left have no icon position
;
makedir >NIL: target:Tools target:Utilities target:System target:Prefs
list target:#?.info target:tools/#?.info target:utilities/#?.info target:system/#?.info target:prefs/#?.info files lformat "iconpos >NIL: *"%p%n*" -1 -1" >t:dinfo
execute t:dinfo
delete t:dinfo quiet

echo "*NInstalling software from the Workbench2.0 disk...*N"
copy Workbench2.0: target: all com
;
; restore their wbconfig.prefs
;
if exists ram:wbconfig.prefs
    copy ram:wbconfig.prefs target:prefs/env-archive/sys/wbconfig.prefs quiet
    delete ram:wbconfig.prefs quiet
endif
;
; if its a BOOT: deal, update their first SetPatch
;
ASSIGN >NIL: exists boot:
if not WARN
  Echo "Updating BOOT:C/SetPatch"
  copy target:C/SetPatch Boot:C quiet
endif
echo "*NFiles from Workbench disk installed."

echo "*NInstalling software from the Extras2.0 disk...*N"
copy Extras2.0: target: com all
echo "*NFiles from Extras disk installed."

echo "*NInstalling software from the AmigaFonts2.0 disk...*N"
set needSSWorkFonts 0
set fontSInstalled 0
; note:  this call requires using the ${target}
execute RAM:RoomForFonts ${target} [test]
if val 5 GT "$fontreturn"
    echo ""
    copy AmigaFonts2.0:fonts target:fonts all com
    set fontSInstalled 1
else
    echo "Warning: There isn't enough room to install the fonts in ${target}"
    ; if we have a work partition
    assign >NIL: exists work:
    if not WARN
        ask "Would you like to install them in WORK: ? (Y/N) "
        if WARN
            copy AmigaFonts2.0:fonts work:fonts all com
            ;
            ; We will need the startup-sequence that understands this into S:
            set needSSWorkFonts 1
            set fontSInstalled 1
        endif
    endif
endif
;
echo "*NThe Outline Font option is recommended for systems having"
echo "at least 1 Megabyte of RAM."
ask "Do you wish to install the Outline Font option ? (Y/N) "
if WARN
    copy AmigaFonts2.0:libs/diskfont.library target:libs all com
    set fontSInstalled 1
endif
;
if $fontSInstalled EQ "1"
    echo "*NFiles from AmigaFonts disk installed."
endif
;
if $needSSWorkFonts EQ "0"
    copy a:s/Startup-Sequence.hd target:s/Startup-Sequence
else
    copy a:s/Startup-Sequence.wf target:s/Startup-Sequence
endif
; Hard disk users need the special version of PickMap
copy a:s/PickMap.hd target:s

delete RAM:RoomForFonts quiet

;
; Refresh anything that's in the Monitors drawer, and pull
; it out of the MonitorStore.
;
if exists target:Monitors
    list target:Monitors lformat "if exists *"target:MonitorStore/%n*"*Ncopy *"target:MonitorStore/%n*" target:Monitors*Ndelete *"target:MonitorStore/%n*" quiet*Nendif" >t:movemonitors
    execute t:movemonitors
    delete t:movemonitors quiet
endif
;
copy a:Copy2WB2/wdisk.info target:disk.info
copy a:Copy2WB2/wsystem.info target:System.info
copy a:Copy2WB2/wtools.info target:Tools.info

Echo "*NInstalling additional tools..."
;
; Copy over an L:FastFileSystem if they had one already
; or this is a full install
;
if "[full]" NOT EQ ""
    echo "ok" >target:l/FastFileSystem
endif
if exists target:l/FastFileSystem
    echo "Placing a 2.0 version of L:FastFileSystem in your L: directory."
    copy a:l/FastFileSystem target:l
endif

; test for scsi device
;
version scsi.device >NIL:
if not warn
    cd ram:
    echo "Updating Rigid Disk Block (filesystem)."
    2.0Install:Prod_prep >NIL: Unit 0 layout 2.0Install:PrepUpScript
; force installation of new HDToolbox
    echo "ok" >target:tools/HDtoolbox
endif

; special tools section
cd a:Tools

if "[full]" NOT EQ ""
    echo "ok" >target:tools/HDtoolbox
endif
if exists target:tools/HDtoolbox
    echo "Placing a 2.0 version of HDToolbox in your SYS:Tools directory."
    copy a:Tools/HDToolbox a:Tools/HDToolbox.info target:Tools quiet
endif

copy Lacer Lacer.info ShowConfig Showconfig.info target:Tools quiet

;
; position icons
echo "*NPositioning new icons..."
iconpos >NIL: target:Trashcan type=GARBAGE 277 38
iconpos >NIL: target:System type=DRAWER 98 4
iconpos >NIL: target:Shell type=PROJECT 16 4
iconpos >NIL: target:Expansion type=DRAWER 280 4
iconpos >NIL: target:Prefs type=DRAWER 3 43
iconpos >NIL: target:Utilities type=DRAWER 98 72
iconpos >NIL: target:WBStartup type=DRAWER 189 72
iconpos >NIL: target:Tools type=DRAWER 98 38
iconpos >NIL: target:MonitorStore type=DRAWER 189 38
iconpos >NIL: target:Monitors type=DRAWER 189 4
iconpos >NIL: target:Trashcan type=GARBAGE 277 38
;
iconpos >NIL: target:System/Fountain type=TOOL 272 4
;
iconpos >NIL: target:Tools/Lacer type=TOOL 7 134
iconpos >NIL: target:Tools/ShowConfig type=TOOL 88 134
if exists target:tools/HDtoolbox
    iconpos >NIL: target:Tools/HDBackup type=TOOL 261 54
    iconpos >NIL: target:Tools/HDtoolbox type=TOOL 269 101
    iconpos >NIL: target:Tools/Commodities type=DRAWER 272 143
endif
;

; default boot to interlace ?
echo "*NWould you like your default system-configuration"
Ask "to be interlace ? (Y/N) "
if warn
    copy a:devs/system-configuration.i target:devs/system-configuration
endif
; check for 2090a
assign >NIL: exists BOOT:
if not warn
    copy target:devs/system-configuration BOOT:devs
endif

; If they have a 2232 installed, we have the updated drivers for them!
if exists target:devs/oldser.device
echo "A2232 detected.  Updating serial.device and oldser.device."
copy a:A2232/serial.device target:devs/serial.device quiet
copy a:A2232/oldser.device target:devs/oldser.device quiet
; we have some information to tell them at the end
endif
;

; run fixfonts on the just installed hard disk
assign fonts: target:fonts
a:System/fixfonts
assign fonts: a:fonts

echo "*EcInstallation of 2.0 Workbench complete."
echo "*NIf needed, you may now customize your User-Startup,"
echo "Shell-Startup and MountList."
echo "You will find your old versions in the ${target}OLD directory."
echo "*NNOTES: Under 2.0 most changes to the Startup-Sequence"
echo "       can be placed in your S:User-Startup file."
echo "       You may have to rearrange and snapshot icons in"
echo "       some of your windows after you reboot."
;
; tell them about special notes
;
if exists target:devs/oldser.device
    echo "*NIf you had installed the special aux-handler and port-handler"
    echo "from the CLI directory of your A2232 Install disk, you must"
    echo "once again install those files."
endif

if exists target:l/FastFileSystem
    echo "*NA new version of the FastFileSystem has been placed in your L:"
    echo "directory.  You can save memory by making hard disks that"
    echo "use L:FastFileSystem use the ROM FastFileSystem instead."
endif

if "${target}" EQ "dh0:"
    echo "*NIf you are booting from floppy, you should install"
    echo "the file 2.0Install:S/S-S_Boot.dh0 as the startup-sequence"
    echo "on your boot floppy disk."
endif

if "${target}" EQ "dh2:"
    echo "*NIf you are booting from floppy, you should install"
    echo "the file 2.0Install:S/S-S_Boot.dh2 as the startup-sequence"
    echo "on your boot floppy disk."
endif

echo "*NPlease remove the 2.0Install disk from the disk drive and"
echo "reboot your machine to use the new commands."
;
lab exit
; remove the temporary installation assignments
assign a:
assign target:
;
cd tempdir:
assign tempdir:
; remove the test aliases and sets
if "[test]" NOT EQ ""
unset echo    
unalias copy
unalias rename
unalias delete
endif
; unset our temporary variables
unset size
unset target
unset needSKeymap
unset needSSWorkFonts
unset newname
lab end
