; $VER: CobbWeb_Install 0.1 (27.3.95)
; Script to install CobbWeb support files for Amiga TCP/IP

; Main script logic starts at 'MAIN INSTALLATION' way below

(set AppVersion "0.1")

; 0% complete
(complete 0)

(set amigaCPU (database "cpu"))
(set packages 0) ; assume nothing is to be installed

;=============================================================================
; What packages need to be installed?

; PPP setup I
(set PPP_ver "1_30")
(set PPP_reg (exists "S:PPP.key"))
(debug "PPP_reg is: " PPP_reg)
(set PPP_lha (cat "PPP" PPP_ver ".lha"))
(debug "PPP_lha is: " PPP_lha)
(set PPP_reglha (cat "PPP" PPP_ver "reg.lha"))
(debug "PPP_reglha is: " PPP_reglha)

; AmiTCP setup I
(set TCP_ver "40")
(set TCP_lha (cat "AmiTCP-demo-" TCP_ver ".lha"))
(debug "TCP_lha is: " TCP_lha)

; MUI setup I
(set MUI_ver "23")
(set MUI_reg (exists "S:MUI.key"))
(debug "MUI_reg is: " MUI_reg)
(set MUI_lha (cat "mui" MUI_ver "usr.lha"))
(debug "MUI_lha is: " MUI_lha)

; AMosaic setup I
(set Mos_ver "1.2")
(set Mos_lha (cat "Mosaic" Mos_ver "AmiTCP.lha"))
(set Mos_pch "1.3beta")
(set Mos_pch_lha (cat "AMosaic" Mos_pch "AmiTCP.lha"))

; ZGIFDataType setup (Installed with Mosaic)
(set GIF_ver "39.9")
(set GIF_lha (cat "ZGIFDType" GIF_ver ".lha"))

; AMS (Installed with Mosaic)
(set AMS_lha "ams.lha")

; EdPlay (Installed with Mosaic)
(set ED_lha "edplay.lha")

;******************************************************************
;******************* LANGUAGE INITIALIZATION **********************
;******************************************************************

;=============================================================================
; Danish strings

(if (= @language "dansk")
(
(set default_lang 1)
))

;=============================================================================
; German strings

(if (= @language "deutsch")
(
(set default_lang 2)
))

;=============================================================================
; English strings

(if (= @language "english")
(
(set default_lang 4)

(set #bad-wb-ver
(cat "\nAMosaic works best with Workbench 3.0 or greater."
))

(set #bad-kick-ver
(cat "You must be using at least Kickstart 2.04 to install these packages."
))

(set #message-intro
(cat "\nThis program installs TCP/IP software on your Amiga hard "
     "drive.  The following freely redistributable software packages "
	 "are installed:\n\n"
		  PPP_lha " by Holger Kruse\n"
		  TCP_lha " by NDSi\n"
		  MUI_lha " by Stefan Stuntz\n"
		  Mos_lha " by Fischer, Witbrock & Meyer\n"
		  GIF_lha " by Michael Zucchi\n"
		  AMS_lha " by David N. Junod\n"
		  ED_lha  " by Ed\n"
		  "\n"
))

(set #welcome-help
(cat ("CobbWeb installation script version %s\n\n" AppVersion)
))

(set #askdir-prompt-CobbWeb
(cat "A directory named CobbWeb will be created.  All of the "
	 "packages will be installed in this directory.  Where would "
	 "you like me to create this directory?"
))

(set #askdir-help-CobbWeb
(cat "Press \"Show Drives\" to get a list of available volumes.  Select "
     "the volume to use for this installation.  You may also select "
	 "a drawer on that volume.  Then press \"Proceed\".  The CobbWeb "
	 "drawer will be created in the directory you specify.\n\n"
     @askdir-help
))

(set #delete-CobbWeb_file-prompt
(cat "A file named CobbWeb has been detected.  I am deleting this file "
     " so that a directory of the same name can be created."
))

(set #delete-CobbWeb_file-help
(cat #delete-CobbWeb_file-prompt
))

(set #makedir-CobbWeb_dir-prompt
(cat "Making CobbWeb directory.\n"
))

(set #makedir-CobbWeb_dir-help
(cat #makedir-CobbWeb_dir-prompt
     @makedir-help
))

(set #askfile-ppp-lha-prompt
(cat "I cannot find the PPP archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-ppp-lha-help
(cat #askfile-ppp-lha-prompt
))

(set #askfile-tcp-lha-prompt
(cat "I cannot find the AmiTCP archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-tcp-lha-help
(cat #askfile-tcp-lha-prompt
))

(set #askfile-mui-lha-prompt
(cat "I cannot find the MUI archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-mui-lha-help
(cat #askfile-mui-lha-prompt
))

(set #askfile-mos12-lha-prompt
(cat "I cannot find the Amiga Mosaic version 1.2 archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-mos12-lha-help
(cat #askfile-mos12-lha-prompt
))

(set #askfile-mos13-lha-prompt
(cat "I cannot find the Amiga Mosaic version 1.3beta archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-mos13-lha-help
(cat #askfile-mos13-lha-prompt
))

(set #askfile-gif-lha-prompt
(cat "I cannot find the ZGIF archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-gif-lha-help
(cat #askfile-gif-lha-prompt
))

(set #askfile-ams-lha-prompt
(cat "I cannot find the AMS archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-ams-lha-help
(cat #askfile-ams-lha-prompt
))

(set #askfile-ed-lha-prompt
(cat "I cannot find the EdPlay archive (.lha) file.  Please select the file I should use.\n"
))

(set #askfile-ed-lha-help
(cat #askfile-ed-lha-prompt
))

(set #askoptions-packages-prompt
(cat "\n"
     "Which packages would you like to have installed? "
     "All of these pacakges are needed "
	 "for a fully functional TCP/IP environment."
))

(set #askoptions-packages-help
(cat  "Check the boxes of the packages you wish "
     "to have available on your system."
     "\n\n"
     "PPP - This is the PPP package by Holger Kruse.  "
     "By selecting this package ppp.device, ppp0.config "
     "and a sample dialscript will be installed. "
     "If you already have a registration key, the "
     "registered version will be installed."
     "\n\n"
     "AmiTCP - This is the demo AmiTCP package by NSDI.  "
     "By selecting this package the full TCP/IP suite "
     "will be installed. The AmiTCP Installation script "
     "will be run, and you will have to provide information "
     "about your TCP/IP setup.  This information should be "
     "availble from your Internet provider. "
     "\n\n"
     "MUI - This is the Magic User Interface package by Stephan Stunz.  "
     "This is required in order to run Amiga Mosaic. "
     "By selecting this package the 2.2 MUI user files "
     "will be installed. "
     "\n\n"
     "AMosaic - This is the Amiga Mosaic package by Fischer, Witbrock & Meyer.  "
     "By selecting this package the 1.2 version of Amiga Mosaic will first be "
     "installed to provide a full set of documentation.  Then the 1.3beta version "
     "of AMosaic alone will be installed.  In addition, several datatype support packages "
	 "will be installed."
     "\n\n"
     @askoptions-help
))

(set #working-makedir-ppp
(cat "Creating PPP directory %s..."
))

(set #makedir-PPP_dir-prompt
(cat "Making CobbWeb/PPP subdirectory.\n\n"
))

(set #makedir-PPP_dir-help
(cat #makedir-PPP_dir-prompt
     @makedir-help
))

(set #working-unarchive-ppp
(cat "Unarchiving PPP to %s directory..."
))

(set #working-unarchive-ppp-reg
(cat "Unarchiving PPP registered version to %s directory..."
))

(set #working-copying-ppp-device
(cat "Copying ppp.device..."
))

(set #copylib-pppdevice-prompt
(cat "Copying ppp.device to devs:networks..."
))

(set #copylib-pppdevice-help
(cat #copylib-pppdevice-prompt
))

(set #working-checking-serial-device
(cat "Checking serial.device..."
))

(set #askfile-serial-device-prompt
(cat "Please select the serial device driver you want to use with PPP.\n"
))

(set #askfile-serial-device-help
(cat #askfile-serial-device-prompt
     @askfile-help
))

(set #working-checking-serial-unit
(cat "Checking serial.device unit number..."
))

(set #asknumber-serial-unit-prompt
(cat "Please select the serial device unit number you want to use with PPP.\n"
))

(set #asknumber-serial-unit-help
(cat #asknumber-serial-unit-prompt
     @asknumber-help
))

(set #working-checking-serial-baud
(cat "Checking serial.device baud rate..."
))

(set #asknumber-serial-baud-prompt
(cat "Please select the serial device baud rate you want to use with PPP.\n"
     "It is advisable to start with a low baud rate like 9600 while setting things up.\n"
))

(set #asknumber-serial-baud-help
(cat #asknumber-serial-baud-prompt
     @asknumber-help
))

(set #working-creating-ppp-config
(cat "Creating the ppp0.config file..."
))

(set #textfile-ppp-config-prompt
(cat "Creating ppp0.config file.\n"
))

(set #textfile-ppp-config-help
(cat #textfile-ppp-config-prompt
))

(set #working-copying-ppp-config
(cat "Copying the ppp0.config file to envarc:..."
))

(set #copyfiles-ppp-config-prompt
(cat "Copying ppp0.config file to envarc:.\n"
))

(set #copyfiles-ppp-config-help
(cat #copyfiles-ppp-config-prompt
))

(set #working-copying-dialscript
(cat "Copying the dialscript file..."
))

(set #copyfiles-dialscript-prompt
(cat "Copying dialscript file...\n"
))

(set #copyfiles-dialscript-help
(cat "This is a sample dialscript file used by PPP. "
     "After the installation, you will have to modify "
	 "this file to accomodate your modem and the "
	 "connection parameters required by your service "
	 "provider.  This file is stored in the CobbWeb:PPP "
	 "directory."
))

(set #working-creating-chapfile
(cat "Creating the chapfile..."
))

(set #textfile-ppp-chapfile-prompt
(cat "Creating PPP chapfile file.\n"
))

(set #textfile-ppp-chapfile-help
(cat #textfile-ppp-chapfile-prompt
))

(set #working-unarchive-tcp
(cat "Unarchiving AmiTCP to %s directory..."
))

(set #working-copyfiles-installer
(cat "Copying newest installer to %s directory..."
))

(set #copyfiles-AmiInstaller-prompt
(cat "Replacing Installer with newer Installer program...\n"
))

(set #copyfiles-AmiInstaller-help
(cat "The Installer program supplied with AmiTCP is version "
     "1.24.  I am replacing this with a newer version. "
))

(set #message-AmiTCP-installer
(cat "\n"
     "AmiTCP has it's own Installer script.  It "
     "installs and configures AmiTCP.  When it asks you where "
	 "to install AmiTCP, accept the default directory.  It also "
	 "asks you questions about your AmiTCP configuration including "
	 "what users will be on your system and what "
	 "IP addresses will be used.  Refer to the information suppied by your "
	 "internet provider to answer these questions.  "
	 "You will need to run the AmiTCP installation after completing this installation."
; "I will wait in the "
; "background while the AmiTCP Installer script is executing..."
))

(set #working-fixing-interfaces
(cat "Copying ixemul.library to libs: directory..."
))

(set #working-copylib-ixemul
(cat "Copying ixemul.library to libs: directory..."
))

(set #copylib-ixemul-prompt
(cat "I need to copy ixemul.library to your libs: directory. "
     "Since this is a commonly used library I will leave it. "
	 "However, you may delete if later if you wish."
))

(set #copylib-ixemul-help
(cat "I will copy ixemul.library to your libs: directory "
     "only if you have an older version."
))

(set #working-makeassign-tmp
(cat "making tmp: assignment..."
))

(set #working-patching-startnet
(cat "Patching the AmiTCP startnet script..."
))

(set #working-patching-startnet
(cat "Patching the AmiTCP stopnet script..."
))

(set #working-fixing-protection
(cat "Fixing the protection bits on the AmiTCP stopnet and netstat scripts..."
))

(set #working-unarchive-mui
(cat "Unarchiving MUI to %s directory..."
))

(set #copyfiles-MUIInstaller-prompt
(cat "Replacing Installer with newer Installer program...\n"
))

(set #copyfiles-MUIInstaller-help
(cat "The Installer program supplied with MUI is version "
     "1.24.  I am replacing this with a newer version. "
))

(set #working-startup-mui
(cat "Adding lines to your user-startup for MUI..."
))

(set #working-makedir-mos
(cat "Creating directory %s..."
))

(set #makedir-mos-prompt
(cat "Making Amiga Mosaic subdirectory.\n"
))

(set #makedir-mos-help
(cat #makedir-mos-prompt
     @makedir-help
))

(set #working-unarchive-mos12
(cat "Unarchiving Mosaic version 1.2 to %s directory..."
))

(set #working-unarchive-mos13
(cat "Unarchiving Mosaic version 1.3beta to %s directory..."
))

(set #working-copying-mos-envarc
(cat "Copying contents of Mosaic's envarc subdirectory to envarc:..."
))

(set #copyfiles-mos-envarc-prompt
(cat "Copying content's of Mosaic's envarc subdirectory to envarc:...\n"
))

(set #copyfiles-mos-envarc-help
(cat #copyfiles-mos-envarc-prompt
))

(set #working-copying-mos-env
(cat "Copying contents of Mosaic's envarc subdirectory to env:..."
))

(set #copyfiles-mos-env-prompt
(cat "Copying content's of Mosaic's envarc subdirectory to env:...\n"
))

(set #copyfiles-mos-env-help
(cat #copyfiles-mos-env-prompt
))

(set #working-copying-mos-rexx
(cat "Copying contents of Mosaic's rexx subdirectory to rexx:..."
))

(set #copyfiles-mos-rexx-prompt
(cat "Copying content's of Mosaic's rexx subdirectory to rexx:...\n"
))

(set #copyfiles-mos-rexx-help
(cat #copyfiles-mos-rexx-prompt
))

(set #working-unarchive-zgif
(cat "Unarchiving ZGIFDType39.9.lha..."
))

(set #working-unarchive-ams
(cat "Unarchiving ams.lha..."
))

(set #working-copylib-ams
(cat "Copying ams.lha files..."
))

(set #copylib-sunau-prompt
(cat "Copying sunau.datatype..."
))

(set #copylib-sunau-help
(cat #copylib-sunau-prompt
))

(set #copylib-xbm-prompt
(cat "Copying xbm.datatype..."
))

(set #copylib-xbm-help
(cat #copylib-xbm-prompt
))

(set #copylib-pic-prompt
(cat "Copying pic.datatype..."
))

(set #copylib-pic-help
(cat #copylib-pic-prompt
))

(set #copylib-ams-prompt
(cat "Copying datatypes directory..."
))

(set #copylib-ams-help
(cat #copylib-ams-prompt
))

(set #working-unarchive-ams
(cat "Unarchiving EdPlay.lha..."
))

(set #startup-add-path-prompt
(cat "Adding startup definitions to your s:user-startup file."
))

(set #startup-add-path-help
(cat #startup-add-path-prompt
))

))


;=============================================================================
; Spanish strings

(if (= @language "espaol")
(
(set default_lang 8)
))


;=============================================================================
; French strings

(if (= @language "franais")
(
(set default_lang 16)
))


;=============================================================================
; Italian strings

(if (= @language "italiano")
(
(set default_lang 32)
))


;=============================================================================
; Dutch strings

(if (= @language "nederlands")
(
(set default_lang 64)
))


;=============================================================================
; Norwegian strings

(if (= @language "norsk")
(
(set default_lang 128)
))


;=============================================================================
; Portugues strings

(if (= @language "portugus")
(
(set default_lang 256)
))


;=============================================================================
; Swedish strings

(if (= @language "svenska")
(
(set default_lang 512)
))


;******************************************************************
;******************* COBBWEB INSTALLTION SCRIPT *******************
;******************************************************************


;==============================================================================
; make sure we are running under at least Kick 2.04 (ver 36) and WB 2.1 (ver 38)

; remember original user level from command line
(set user_level @user-level)

; set expert mode so users will see the next message on error
(user 2)

(set WB_ver (/ (getversion "libs:version.library") 65536))
(debug "WB_ver is: " WB_ver)
(if (< WB_ver 39)
(
    (message #bad-wb-ver)
))

(set KS_ver (/ (getversion) 65536))
(debug "KS_ver is: " KS_ver)
(if (< KS_ver 36)
(
    (abort #bad-kick-ver)
))

;=============================================================================
; where are we executing from?

; what directory are we installing from?
(set sourcePath (expandpath (pathonly @icon)))
(if (= "" sourcePath)
   (abort "sourcePath undefined")
)

;=============================================================================
; clear global copy/delete options

; clear options for copyfiles, copylib and delete
;    oknodelete -- aborts if can't copy unless reason was "delete protected"
;    askuser    -- if NOT in novice mode, ask user for permission to override file protection
;    force      -- unprotect destination, then delete (make default permission request 'yes')
(delopts "oknodelete" "askuser" "force")

;=============================================================================
; put up a little intro screen saying what we're doing

; tell user what we're up to
(message #message-intro)
(user user_level) ; restore user level

;=============================================================================
; put up standard welcome screen

; now (instead of at beginning) put up welcome messaage
; this requests the user level from the user
(user user_level)            ; restore default user level
(welcome #welcome-help)
(set user_level @user-level) ; remember what the user selected

;=============================================================================
; decide what our best @default-dest installation directory should be

; if CobbWeb: assignment already exists, use it
(set @default-dest "CobbWeb:") ; default installation location
(if (set CobbWeb_assign (getassign "CobbWeb"))
(
   (set @default-dest CobbWeb_assign) ; default installation location
))
(debug "@default-dest is: " @default-dest)

;=============================================================================
; let user make final decision on (parent of) @default-dest

; query user for place to install (one level up from @default-dest)
(set parentDir (pathonly @default-dest)) ; default installation location parent
(debug "default parentDir is: " parentDir)
(user 1)
(set parentDir
   (askdir (disk)
      (prompt #askdir-prompt-CobbWeb)
      (help #askdir-help-CobbWeb)
      (disk)
      (default parentDir) ; what heppens if the default doesn't exist on their machine?
   )
)
(user user_level)
(debug "final parentDir is: " parentDir)
(set @default-dest (tackon parentDir "CobbWeb"))
(set CobbWeb_dir @default-dest)
(debug "CobbWeb_dir is: " CobbWeb_dir)

;=============================================================================
; create CobbWeb_dir if necessary

; is CobbWeb_dir currently a *file*? If so, delete it
(if (= 1 (exists CobbWeb_dir (noreq))) ; its a file
(
   (debug "deleting file " CobbWeb_dir)
   (user 2) ; force confirmation
   (delete CobbWeb_dir
      (prompt #delete-CobbWeb_file-prompt)
	  (help   #delete-CobbWeb_file-help)
	  (confirm)
	  (optional "force" "askuser")
   )
   (delete (cat CobbWeb_dir ".info")) ; just in case it exists
   (user user_level) ; restore user level
))

(if (<> 2 (exists CobbWeb_dir (noreq))) ; its not a directory
(
   (debug "creating directory " CobbWeb_dir)
   (makedir CobbWeb_dir
      (prompt #makedir-CobbWeb_dir-prompt)
      (help #makedir-CobbWeb_dir-help)
      (confirm)
      (infos)
   )
))

;=============================================================================
; What packages need to be installed?

; PPP setup II
(if (NOT (exists PPP_lha))
(
   (set PPP_lha 
      (askfile 
         (prompt #askfile-ppp-lha-prompt)
	     (help   #askfile-ppp-lha-help)
	     (default PPP_lha)
      )
   )
))
(set PPP_dir (tackon CobbWeb_dir "PPP"))
(debug "PPP_dir is: " PPP_dir)
(set PPP_dialscript (tackon PPP_dir "dialscript"))
(debug "PPP_dialscript is: " PPP_dialscript)
(set PPP_chapfile (tackon PPP_dir "chapfile"))
(debug "PPP_chapfile is: " PPP_chapfile)
(set PPP_bit 1)
(if (NOT (exists PPP_chapfile))
   (set packages (BITOR packages PPP_bit))
)

; AmiTCP setup II
(if (NOT (exists TCP_lha))
(
   (set TCP_lha 
      (askfile 
         (prompt #askfile-tcp-lha-prompt)
	     (help   #askfile-tcp-lha-help)
	     (default TCP_lha)
      )
   )
))
(set TCP_dir (tackon CobbWeb_dir "AmiTCP-4.0"))
(debug "TCP_dir is: " TCP_dir)
(set TCP_interfaces (tackon TCP_dir "db/interfaces"))
(debug "TCP_interfaces is: " TCP_interfaces)
(set TCP_bit 2)
(if (= (getsize (tackon TCP_dir "bin/stopnet")) 230)
   (set packages (BITOR packages TCP_bit))
)

; MUI setup II
(if (NOT (exists MUI_lha))
(
   (set MUI_lha 
      (askfile 
         (prompt #askfile-mui-lha-prompt)
	     (help   #askfile-mui-lha-help)
	     (default MUI_lha)
      )
   )
))
(set MUI_dir (tackon CobbWeb_dir "MUI"))
(debug "MUI_dir is: " MUI_dir)
(set MUI_bit 4)
(if (<> (getsize (tackon MUI_dir "Installer")) 61640)
   (set packages (BITOR packages MUI_bit))
)

; AMosaic setup II
(if (NOT (exists Mos_lha))
(
   (set Mos_lha 
      (askfile 
         (prompt #askfile-mos12-lha-prompt)
	     (help   #askfile-mos12-lha-help)
	     (default Mos_lha)
      )
   )
))
(if (NOT (exists Mos_pch_lha))
(
   (set Mos_pch_lha 
      (askfile 
         (prompt #askfile-mos13-lha-prompt)
	     (help   #askfile-mos13-lha-help)
	     (default Mos_pch_lha)
      )
   )
))
(set Mos_dir (tackon CobbWeb_dir (cat "Mosaic_" Mos_ver "_AmiTCP")))
(set Mos_bit 8)

; AMS (Installed with Mosaic)
(if (NOT (exists AMS_lha))
(
   (set AMS_lha 
      (askfile 
         (prompt #askfile-ams-lha-prompt)
	     (help   #askfile-ams-lha-help)
	     (default AMS_lha)
      )
   )
))
(set AMS_dir (tackon CobbWeb_dir "AMS"))

; EdPlay (Installed with Mosaic)
(if (NOT (exists ED_lha))
(
   (set ED_lha 
      (askfile 
         (prompt #askfile-ed-lha-prompt)
	     (help   #askfile-ed-lha-help)
	     (default ED_lha)
      )
   )
))
(if (NOT (exists (tackon CobbWeb_dir "edplayer/EdPlayerJr.info")))
   (set packages (BITOR packages Mos_bit))
)

; General CobbWeb setup
(set CobbBin_dir (tackon CobbWeb_dir "bin"))

(set packages 
      (askoptions 
	     (prompt #askoptions-packages-prompt)
         (help   #askoptions-packages-help)
		 (choices "PPP" "AmiTCP" "MUI" "AMosaic")
		 (default packages)
	  )
)
(debug "packages is: " packages)

;------- skip this for now -------
;(if 0
;(

;=============================================================================
; install PPP

(debug "PPP_bit is: " PPP_bit)

(if (BITAND PPP_bit packages)
(
   (working (#working-makedir-ppp PPP_dir))
   (if (NOT (exists (cat PPP_dir ".info") (noreq)))
   (
      (debug "creating directory " PPP_dir)
      (makedir PPP_dir
         (prompt #makedir-PPP_dir-prompt)
         (help #makedir-PPP_dir-help)
         (confirm)
         (infos)
      )
   ))
   (working (#working-unarchive-ppp PPP_dir))
   (if (NOT (exists (tackon PPP_dir "REGISTRATION")))
   (
      (debug "Unarchiving PPP")
      (run (cat "lha -r -a -x x " PPP_lha " " CobbWeb_dir "/"))
   ))
   (working (#working-unarchive-ppp-reg PPP_dir))
   (if (AND PPP_reg (NOT (exists (tackon PPP_dir "devs/ppp.device.020"))))
   (
      (debug "Unarchiving PPPreg")
      (run (cat "lha -r -a -x x " PPP_reglha " " CobbWeb_dir "/"))
   ))
   ; copy ppp.device
   (working #working-copying-ppp-device)
   (if (patmatch "680(0|1)0" amigaCPU)
   (
      (debug "68000/68010 detected")
      (if (exists "S:PPP.key")
         (set PPPsource "devs/ppp.device.000")
	  ; else
         (set PPPsource "devs/ppp.device.000.eval")
      )
      (debug "copying " (tackon PPP_dir PPPsource))
      (copylib
         (prompt #copylib-pppdevice-prompt)
         (help #copylib-pppdevice-help)
	     (source (tackon PPP_dir PPPsource))
		 (dest "devs:networks")
		 (newname "ppp.device")
		 (infos)
		 (confirm)
      )
   )
   ;else  68020 and higher
   (
      (debug "68020/68030/68040 detected")
      (if (exists "S:PPP.key")
         (set PPPsource "devs/ppp.device.020")
	  ; else
         (set PPPsource "devs/ppp.device.020.eval")
      )
      (debug "copying " (tackon PPP_dir PPPsource))
      (copylib
         (prompt #copylib-pppdevice-prompt)
         (help #copylib-pppdevice-help)
	     (source (tackon PPP_dir PPPsource))
		 (dest "devs:networks")
		 (newname "ppp.device")
		 (infos)
		 (confirm)
      )
   ))
   ; ask for serial.device and unit number
   (working #working-checking-serial-device)
   (debug "asking for serial device")
   (set serdev
      (askfile 
         (prompt #askfile-serial-device-prompt)
	     (help   #askfile-serial-device-help)
	     (default "devs:serial.device")
      )
   )
   (debug "serial device is: " serdev)
   (working #working-checking-serial-unit)
   (debug "asking for unit number")
   (set sernum
      (asknumber
         (prompt #asknumber-serial-unit-prompt)
	     (help   #asknumber-serial-unit-help)
	     (range 0 128)
	     (default 0)
      )
   )
   (debug "unit number is: " sernum)
   (working #working-checking-serial-baud)
   (debug "asking for baud rate")
   (set serbaud
      (asknumber
         (prompt #asknumber-serial-baud-prompt)
	     (help   #asknumber-serial-baud-help)
	     (range 300 115200)
	     (default 9600)
      )
   )
   (debug "baud rate is: " serbaud)
   ; create ppp0.config
   (working #working-creating-ppp-config)
   (if (NOT (exists "env:sana2/ppp0.config"))
   (
      (debug "creating ppp0.config")
      (textfile 
         (prompt #textfile-ppp-config-prompt)
         (help   #textfile-ppp-config-help)
         (dest "env:sana2/ppp0.config")
	     (append (cat serdev " " sernum " " serbaud " 0.0.0.0 7WIRE "
	                  "DIALSCRIPT=" PPP_dialscript " CHAP=" PPP_chapfile))
      )
   ))
   ; copy ppp0.config to envarc:
   (working #working-copying-ppp-config)
   (if (NOT (exists "envarc:sana2/ppp0.config"))
   (
      (debug "copying ppp0.config to envarc:")
      (copyfiles
         (prompt #copyfiles-ppp-config-prompt)
         (help   #copyfiles-ppp-config-help)
         (source "env:sana2/ppp0.config")
         (dest "envarc:sana2")
	     (confirm)
      )
   ))
   ; copy dialscript to PPP_dir
   (working #working-copying-dialscript)
   (if (NOT (exists PPP_dialscript))
   (
      (debug "copying dialscript to " PPP_dir)
      (copyfiles
         (prompt #copyfiles-dialscript-prompt)
         (help   #copyfiles-dialscript-help)
         (source "dialscript")
         (dest PPP_dir)
	     (confirm)
      )
   ))
   ; create CHAP file
   (working #working-creating-chapfile)
   (if (NOT (exists PPP_chapfile))
   (
      (debug "creating CHAP file" PPP_chapfile)
      (textfile 
         (prompt #textfile-ppp-chapfile-prompt)
         (help   #textfile-ppp-chapfile-help)
         (dest PPP_chapfile)
	     (append "his_hostid password your_hostid")
      )
   ))
))

;=============================================================================
; install AmiTCP

(debug "TCP_bit is: " TCP_bit)

(if (BITAND TCP_bit packages)
(
   (working (#working-unarchive-tcp TCP_dir))
   (if (NOT (exists (tackon TCP_dir "serv/netfs-server")))
   (
      (debug "Unarchiving TCP")
      (run (cat "lha -r -a -x x " TCP_lha " " CobbWeb_dir "/"))
   ))
   ; copy our Installer to AmiTCP (for grins)
   (working (#working-copyfiles-installer TCP_dir))
   (if (<> (getsize (tackon TCP_dir "Installer")) 61640)
   (
      (copyfiles
         (prompt #copyfiles-AmiInstaller-prompt)
         (help   #copyfiles-AmiInstaller-help)
         (source "Installer")
         (dest TCP_dir)
	     (confirm)
      )
   ))
   (user 1) ; so we can see the messages 
   (message #message-AmiTCP-installer)
   (debug (cat "Installer " (tackon TCP_dir "Install_AmiTCP") " APPNAME AmiTCP/IP MINUSER AVERAGE"))
   (set @execute-dir TCP_dir)
   ;(run (cat "Installer " (tackon TCP_dir "Install_AmiTCP") " APPNAME AmiTCP/IP MINUSER AVERAGE"))
   ;(message #message-AmiTCP-installer)
   (user user_level)
   ; need to add ppp0 entry to interfaces file
   (working #working-fixing-interfaces)
   (if (< (getsize TCP_interfaces) 5674)
   (
      (debug "adding ppp0 entry to interfaces file")
      (run 
         (cat "echo "
	          "\"ppp0 DEV=DEVS:Networks/ppp.device UNIT=0 IPTYPE=33 NOARP P2P IPREQ=8 WRITEREQ=8\""
		      " >> " TCP_interfaces)
      )
   ))
   ; copy libs/ixemul.llibrary to LIBS: (needed for patch program)
   (working #working-copylib-ixemul)
   (debug "copying ixemul.library to libs:")
   (copylib
      (prompt #copylib-ixemul-prompt)
      (help   #copylib-ixemul-help)
	  (source "libs/ixemul.library")
      (dest "libs:")
      (confirm)
   )
   ; assign tmp: (needed for patch)
   (working #working-makeassign-tmp)
   (if (NOT (getassign "tmp"))
   (
      (makeassign "tmp" "t:")
   ))
   (if (= (getsize (tackon TCP_dir "bin/startnet")) 732)
   (
      ; apply patch to startnet
      (working #working-patching-startnet)
      (debug "patching AMITCP:bin/startnet")
      (set @execute-dir (tackon TCP_dir "bin"))
      (debug "executing from: " @execute-dir)
      (debug 
         (cat (tackon sourcePath "patch") " startnet " (tackon sourcePath "startnet.diff")
	     )
      )
      (run 
         (cat (tackon sourcePath "patch") " startnet " (tackon sourcePath "startnet.diff")
	     )
      )
   ))
   ; need to patch stopnet also
   (if (= (getsize (tackon TCP_dir "bin/stopnet")) 230)
   (
      ; apply patch to stopnet
      (working #working-patching-stopnet)
      (debug "patching AMITCP:bin/stopnet")
      (set @execute-dir (tackon TCP_dir "bin"))
      (debug "executing from: " @execute-dir)
      (debug 
         (cat (tackon sourcePath "patch") " stopnet " (tackon sourcePath "stopnet.diff")
	     )
      )
      (run 
         (cat (tackon sourcePath "patch") " stopnet " (tackon sourcePath "stopnet.diff")
	     )
      )
   ))
   (working #working-fixing-protection)
   ; add +s bit to amitcp:bin/startnet
   (protect (tackon TCP_dir "bin/startnet") "+s")
   ; add +s bit to amitcp:bin/stopnet
   (protect (tackon TCP_dir "bin/stopnet") "+s")
))

;=============================================================================
; install MUI

(debug "MUI_bit is: " MUI_bit)

(if (BITAND MUI_bit packages)
(
   (working (#working-unarchive-mui MUI_dir))
   (if (NOT (exists (tackon MUI_dir "Rexx/WbMan.mrx.info")))
   (
      (debug (cat "lha -r -a -x x " MUI_lha " " CobbWeb_dir "/"))
      (set @execute-dir sourcePath)
      (run (cat "lha -r -a -x x " MUI_lha " " CobbWeb_dir "/"))
   ))
   ; copy our Installer to MUI (for grins)
   (working (#working-copyfiles-installer MUI_dir))
   (if (<> (getsize (tackon MUI_dir "Installer")) 61640)
   (
      (copyfiles
         (prompt #copyfiles-MUIInstaller-prompt)
         (help   #copyfiles-MUIInstaller-help)
         (source "Installer")
         (dest MUI_dir)
	     (confirm)
      )
   ))
   (working #working-startup-MUI)
   (startup "MUI"
      (prompt "Some required commands will be added to your \"s:user-startup\" file.")
      (help @startup-help)
      (command "if exists \"" MUI_dir "\"\n")
      (command "   assign MUI: \"" MUI_dir "\"\n")
      (command "   if exists MUI:Libs\n")
      (command "      assign add LIBS: MUI:Libs\n")
      (command "   endif\n")
      (command "   if exists MUI:Locale\n")
      (command "      assign add LOCALE: MUI:Locale\n")
      (command "   endif\n")
      (command "   version >nil: exec.library 39\n")
      (command "   if not warn\n")
      (command "      if exists MUI:Docs\n")
      (command "         if exists HELP:dummy ; do not remove\n")
      (command "         endif                ; this entry!\n")
      (command "         assign add HELP: MUI:Docs\n")
      (command "      endif\n")
      (command "   endif\n")
      (command "endif")
   )
))

;))
;------- end of skipped section -------

;=============================================================================
; install AMosaic

(debug "Mos_bit is: " Mos_bit)

(if (BITAND Mos_bit packages)
(
   (working (#working-makedir-mos Mos_dir))
   (if (NOT (exists (cat Mos_dir ".info") (noreq)))
   (
      (debug "creating directory " Mos_dir)
      (makedir Mos_dir
         (prompt #makedir-mos-prompt)
         (help   #makedir-mos-help)
         (confirm)
         (infos)
      )
   ))
   (working (#working-unarchive-mos12 Mos_dir))
   (if (NOT (exists (tackon Mos_dir "Rexx/soxaudio.rexx")))
   (
      (debug (cat "lha -r -a -x x " Mos_lha " " CobbWeb_dir "/"))
      (set @execute-dir sourcePath)
      (run (cat "lha -r -a -x x " Mos_lha " " CobbWeb_dir "/"))
   ))
   (working (#working-unarchive-mos13 Mos_dir))
   (if (NOT (exists (tackon Mos_dir "Amosaic.info")))
   (
      (debug (cat "lha -r -a -x x " Mos_pch_lha " " Mos_dir "/"))
      (set @execute-dir sourcePath)
      (run (cat "lha -r -a -x x " Mos_pch_lha " " Mos_dir "/"))
   ))
   ; copy ENVARC drawer to ENV: and ENVARC:
   (working #working-copying-mos-envarc)
   (if (NOT (exists "envarc:Mosaic/prefs.info"))
   (
      (debug "copying " (tackon Mos_dir "envarc") " to envarc:")
      (copyfiles
         (prompt #copyfiles-mos-envarc-prompt)
         (help   #copyfiles-mos-envarc-help)
         (source (tackon Mos_dir "envarc"))
         (dest "envarc:")
	     (all)
	     (infos)
	     (confirm)
      )
   ))
   (working #working-copying-mos-env)
   (if (NOT (exists "env:Mosaic/prefs.info"))
   (
      (debug "copying " (tackon Mos_dir "envarc") " to env:")
      (copyfiles
         (prompt #copyfiles-mos-env-prompt)
         (help   #copyfiles-mos-env-help)
         (source (tackon Mos_dir "envarc"))
         (dest "env:")
	     (all)
	     (infos)
	     (confirm)
      )
   ))
   ; copy REXX drawer to REXX:
   (working #working-copying-mos-rexx)
   (if (NOT (exists "rexx:soxaudio.rexx"))
   (
      (debug "copying rexx to rexx:")
      (copyfiles
         (prompt #copyfiles-mos-rexx-prompt)
         (help   #copyfiles-mos-rexx-help)
         (source (tackon Mos_dir "rexx"))
         (dest "rexx:")
	     (all)
	     (infos)
	     (confirm)
      )
   ))
   ; set NNTPSERVER to server's IP address
   ; patch mailcap
   ; set MUI preferences to interleaved
   ; ------- Mosaic datatypes -------
   ; ZGIF
   (working #working-unarchive-zgif)
   (if (NOT (exists "devs:datatypes/GIF.info"))
   (
      (set @execute-dir sourcePath)
      (debug (cat "lha -r -a -x x " GIF_lha " sys:classes/datatypes/ gif.datatype"))
      (run (cat "lha -r -a -x x " GIF_lha " sys:classes/datatypes/ gif.datatype"))
      (debug (cat "lha -r -a -x x " GIF_lha " devs: Datatypes/GIF*"))
      (run (cat "lha -r -a -x x " GIF_lha " devs: Datatypes/GIF*"))
   ))
   ; AMS
   (working #working-unarchive-ams)
   (if (NOT (exists (tackon CobbWeb_dir "AMS/readme")))
   (
      (set @execute-dir sourcePath)
      (debug (cat "lha -r -a -x x " AMS_lha " " CobbWeb_dir "/"))
      (run (cat "lha -r -a -x x " AMS_lha " " CobbWeb_dir "/"))
   ))
   (working #working-copylib-ams)
   (if (NOT (exists "devs:datatypes/X-Bitmap.info"))
   (
      ; Install the classes
      (debug "copying AMS classes to SYS:Classes/Datatypes/")
      (copylib
         (prompt #copylib-sunau-prompt)
         (help   #copylib-sunau-help)
         (source (tackon AMS_dir "classes/datatypes/sunau.datatype"))
         (dest "sys:Classes/DataTypes")
         (confirm)
      )
      (copylib
         (prompt #copylib-xbm-prompt)
         (help   #copylib-xbm-help)
         (source (tackon AMS_dir "classes/datatypes/xbm.datatype"))
         (dest "sys:Classes/DataTypes")
         (confirm)
      )
      (copylib
         (prompt #copylib-pic-prompt)
         (help   #copylib-pic-help)
         (source (tackon AMS_dir "classes/datatypes/picture.datatype"))
         (dest "sys:Classes/DataTypes")
         (confirm)
      )
      ; Install the descriptors
      (debug "copying AMS datatypes to DEVS:Datatypes/")
      (copyfiles
         (prompt #copyfiles-ams-prompt)
         (help   #copyfiles-ams-help)
         (source (tackon AMS_dir "devs"))
         (dest "DEVS:")
         (all)
         (infos)
         (confirm)
      )
   ))
   ; EdPlayer
   (working #working-unarchive-edplay)
   (if (NOT (exists (tackon CobbWeb_dir "edplayer/EdPlayerJr.info")))
   (
      (set @execute-dir sourcePath)
      (debug (cat "lha -r -a -x x EdPlay.lha " CobbWeb_dir "/"))
      (run (cat "lha -r -a -x x EdPlay.lha " CobbWeb_dir "/"))
   ))
   ; patch mailcap
   ; Tell the system about the new descriptors
   (debug "C:AddDataTypes Refresh")
   (run "C:AddDataTypes Refresh")
))

; muck with s:user-startup
(debug "modifying user-startup")
(startup "CobbWeb" 
   (prompt #startup-add-path-prompt)
   (help   #startup-add-path-help)
   (command (cat "path " (tackon PPP_dir "bin") " add\n"))
   (command (cat "path " Mos_dir " add\n"))
   (command (cat "path " (tackon CobbWeb_dir "edplayer") " add\n"))
   (command "setenv PAGER more\n")
   (command (cat "assign tmp: t:\n"))
   (command (cat "assign Mosaic: " (tackon Mos_dir "docs") "\n"))
   (command (cat "assign CobbWeb: " CobbWeb_dir "\n"))
   (command (cat "assign HOME: " CobbWeb_dir "\n"))
   ; set NNTPSERVER to server's IP address
)

(exit (cat "That's as much as this script currently performs.  Now you will have to:\n"
		   "(1) Run the AmiTCP Installation in the " TCP_dir " directory.\n"
		   "(2) Edit the dialscript file in the " PPP_dir " directory.  "
           "You may need to look at the PPP documentation to perform this modification.\n"
		   "(3) Reboot your Amiga!  "
))


