FORM  ó`PTCHVERS   $   SAS Institute, Inc. Patch V6.50 INPF    J%R  ž^/Config_AmiTCPOUTF    O£Ö :Config AmiTCPPSEQ  ņģuJĮ uO²UõsHiT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
iO
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;u#si13"))

(welcome "    Welcome to the " app-name " csię.\n")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Initialization
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set 
 ;;
 ;; The name of the sourcesi¹;;
 source-dir (if (= 1 (exists @icon))
		(pathonly (expandpath @icon))
	      (expandpath @icon))
 ;;
 ;; Destination directories of the AmiTCP/IP installation
 ;;
 atcp-name "AmiTCP"
s*i>(cat atcp-name ":")	; Assign to AmiTCP
 ;; Configuration
 confsidb")
 ;; User binaries
 binsibin")
 ;; documentation
 docsi!doc")
 ;; devices directory
 devsS¾iędevs")
 ;; AmigaGuide documentation
 help-dir (tackon atcp-assign "help")
 ;; DOS handlers
 l-dir (tackon atcp-assign "l")
 ;; libraries
 libs-dir (tackon atcp-assign "libs")
 ;; daemons
 serv-dir (tackon atcp-assign "serv")
 
 ;;u$si ;;suFsi
 
 ;;
 u,si ;;
i
 s[suÕsuio;;;
;;; Common subroutines
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
U%siof range 0-255 i"
		  "u,i	formally ursiof wrong formatUēĮ
uNiv;
;;;
;;; Provider profile support
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SOiparse-providers2iČParse existing interface configuration using external tool "parseconfig"
 ;; initialize options known by us based on the results.
 ;; If interface is not configured, initialize to reasonable defaults.SIee provider file name is taken in pro_FileName
 ;;
 (set base-name ""
      ;;
      ;; Set reasonable defaults
      ;;
      pro_Name		"Default"
      pro_DialUp	1
      pro_Interface	"slip"
      pro_NeedSerial	1
      pro_IPDynamic	0
      pro_IPAddr	""		;ask
      pro_DestIP	""		;ask
      pro_Gateway	""		;ask
      pro_Netmask	""		;ask
      pro_NSDynamic	0
      pro_UseBootP	0
      pro_MTU		576
      pro_Phone		""
      pro_HdrCompress	"AUTO"
      pro_PAPHostId	""
      pro_PAPPassword	""
      pro_CHAPHisHostId	""
      pro_CHAPPassword	""
      pro_CHAPHostId	""
      )
 (if (<> pro_FileName "")
Sieexists pro_FileName)
	 (if (= (run (cat "AmiTCP:util/parseconfig CONFIGFILE " pro_FileName) (safe)) 0s_I	fenv-base-name "ENV:Config_AmiTCP/Provider/"
		  base-name "Config_AmiTCP/Provider/"
		  pro_Name (if (exists (cat env-base-name "Name"))
			       (getenv (cat base-name "Name")) "")
		  pro_DialUp (if (exists (cat env-base-name "DialUp"))
				    (+ (getenv (cat base-name "DialUp")) 0))
		  pro_Interface (if (exists (cat env-base-name "Interface"))
				   (getenv (cat base-name "Interface")) "")
		  pro_NeedSerial (if (exists (cat env-base-name "NeedSerial"))
				     (+ (getenv (cat base-name "NeedSerial")) 0))
		  pro_IPDynamic (if (exists (cat env-base-name "IPDynamic"))
				    (+ (getenv (cat base-name "IPDynamic")) 0))
		  pro_IPAddr (if (exists (cat env-base-name "IPAddr"))
				 (getenv (cat base-name "IPAddr")) "")
		  pro_DestIP (if (exists (cat env-base-name "DestIP"))
				 (getenv (cat base-name "DestIP")) "")
		  pro_Gateway (if (exists (cat env-base-name "Gateway"))
				 (getenv (cat base-name "Gateway")) "")
		  pro_Netmask (if (exists (cat env-base-name "Netmask"))
				 (getenv (cat base-name "Netmask")) "")
		  pro_NSDynamic (if (exists (cat env-base-name "NSDynamic"))
				    (+ (getenv (cat base-name "NSDynamic")) 0))
		  pro_UseBootP (if (exists (cat env-base-name "UseBootP"))
				   (+ (getenv (cat base-name "UseBootP"))0))
		  pro_MTU (if (exists (cat env-base-name "MTU"))
			      (+ (getenv (cat base-name "MTU")) 0))
		  pro_Phone (if (exists (cat env-base-name "Phone"))
				(getenv (cat base-name "Phone")) "")
		  pro_HdrCompress (if (exists (cat env-base-name "HdrCompress"))
				      (getenv (cat base-name "HdrCompress")) "")
		  pro_PAPHostId (if (exists (cat env-base-name "PAPHostId"))
				    (getenv (cat base-name "PAPHostId")) "")
		  pro_PAPPassword (if (exists (cat env-base-name "PAPPassword"))
				      (getenv (cat base-name "PAPPassword")) "")
		  pro_CHAPHisHostId (if (exists (cat env-base-name "CHAPHisHostId"))
					(getenv (cat base-name "CHAPHisHostId")) "")
		  pro_CHAPPassword (if (exists (cat env-base-name "CHAPPassword"))
				       (getenv (cat base-name "CHAPPassword")) "")
		  pro_CHAPHostId (if (exists (cat env-base-name "CHAPHostId"))
				     (getenv (cat base-name "CHAPHostId")) "")
		  ))))

 )

(procedure
 save-provider-config
 (set append-default-script
      (and (not (exists "ENV:Config_AmiTCP/Provider/DialScript"))
	   pro_NeedSerial))
 (if append-default-script
     (set append-default-script
	  (askbool
	s³iQYour serial configuration might need "
		   "a dialing script to be included intoSi"provider profile file " pro_FileName ".\n\n"
		   "Do you want the default dialing script for manual "
		   "dial-in to be automatically attached?")
	S¼IĢIf your serial line is a dedicated one (null "
		 "modem cable etc.), and does not need a dialing "
		 "script, then answer \"No\".")
	   )))
 (textfile (dest pro_FileName)
	   (append
	    (cat "/* Provider Configuration Follows:"
		 "\nName          " pro_Name
		 "\nDialUp        " pro_DialUp
		 "\nInterface     " pro_Interface
		 "\nNeedSerial    " pro_NeedSerial
		 "\nIPDynamic     " pro_IPDynamic
		 "\nIPAddr        " pro_IPAddr
		 "\nDestIP        " pro_DestIP
		 "\nGateway       " pro_Gateway
		 "\nNetmask       " pro_Netmask
		 "\nNSDynamic     " pro_NSDynamic
		 "\nUseBootP      " pro_UseBootP
		 "\nMTU           " pro_MTU
		 "\nPhone         " pro_Phone
		 "\nHdrCompress   " pro_HdrCompress
;		 "\nPAPHostId     " pro_PAPHostId
;		 "\nPAPPassword   " pro_PAPassword
;		 "\nCHAPHisHostId " pro_CHAPHisHostId
;		 "\nCHAPPassword  " pro_CHAPPassword
;		 "\nCHAPHostId    " pro_CHAPHostId
		 "\n*/\n"))
	   (if (exists "ENV:Config_AmiTCP/Provider/DialScriptsixinclude "ENV:Config_AmiTCP/Provider/DialScript")
	     (if append-default-script 
		 (include "AmiTCP:ssrx/Default.ssrx"sSi)
	     )
	   )
 (if append-default-script
     (message
      "\n"
      "  The default (manual) dialing script was appended to your "
 SńI" profile file " pro_FileName "."))
 )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; db/(auto)interfaces support
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 parse-if-config
 ;;
 ;; Parse existing interface configuration using external tool "parseconfig"
 ;; initialize options known by us based on the results.
 ;; If interface is not configured, initialize to reasonable defaults.
 ;;
 ;; The interface name is taken in pro_Interface
 ;;
 (set base-name ""
      ;;
      ;; Set reasonable default values
      ;;
      ifc_Device	""
      ifc_Unit		0
      ifc_Serial	0
      ifc_SerDevName	"serial.device"
      ifc_SerUnitNum	0
      ifc_SerBaud	9600
      ifc_SerBufLen	16384
      ifc_CD		0
      ifc_7Wire		1
      ifc_NoEOFMode	0
      ifc_UseODU	0
      ifc_Shared	1
      )
 (if (<> pro_Interface "")
     (if (= (run (cat "AmiTCP:util/parseconfig INTERFACE " pro_Interface) (safe)) 0)
	 ((set env-base-name (cat "ENV:Config_AmiTCP/if/" pro_Interface "/sEi3base-name (cat "Config_AmiTCP/if/" pro_Interface "/sibifc_Device (if (exists (cat env-base-name "Device"))
			      (getenv (cat base-name "Device")) ""S¾i\ifc_Unit (if (exists (cat env-base-name "Unit"))
			    (+ (getenv (cat base-name "Unit")) 0sĮi9 )
	  (if (= 2 (exists (cat env-base-name "SerialConfig")SęI±(set
	       ifc_Serial 1
	       env-base-name (cat env-base-name "SerialConfig/")
	       base-name (cat base-name "SerialConfig/")
	       ifc_SerDevName (if (exists (cat env-base-name "SerDevName"))
				  (getenv (cat base-name "SerDevName")) "")
	       ifc_SerUnitNum (if (exists (cat env-base-name "SerUnitNum"))
				  (+ (getenv (cat base-name "SerUnitNum")) 0))
	       ifc_SerBaud (if (exists (cat env-base-name "SerBaud"))
			       (+ (getenv (cat base-name "SerBaud")) 0))
	       ifc_SerBufLen (if (exists (cat env-base-name "SerBufLen"))
				 (+ (getenv (cat base-name "SerBufLen")) 0))
	       ifc_CD (if (exists (cat env-base-name "CD")) 1 0)
	       ifc_7Wire (if (exists (cat env-base-name "7Wire")) 1 0)
	       ifc_NoEOFMode (if (exists (cat env-base-name "NoEOFMode")) 1 0)
	       ifc_UseODU (if (exists (cat env-base-name "UseODU")) 1 0)
	       ifc_Shared (if (exists (cat env-base-name "Shared")) 1 0)
	       )))))
 )
uRix;;;
;;; Serial device configuration
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
s!i&serial-config

 ;;
 ;; parse-if-configsicalleds
sÓie device configurationsithe interfaces entry on the
 ;; db/interfaces. This procedure handles the SERIAL specific options and
 ;; returns them in if-serialSwi½;; The options we support are:
 ;;
 ;; ifc_SerDevName - serial device
 ;; ifc_SerUnitNum - serial device unit
 ;; ifc_SerBaud - serial line bit rate
 ;; ifc_SerBufLen - serial buffer lengths8i16384) (not asked)
 ;; ifc_CD - Carrier detect
 ;; ifc_7Wire - Hardware flow control (recommended)
 ;; ifc_NoEOFMode - EOF-mode ofsŪiņnot supported
 ;; ifc_UseODU - Use OwnDevUnit.library to regulate serial device access
 ;; ifc_Shared - use serial in shared mode
 ;;
 
 (transcript "Asking SERIAL options.")
 ;;
 ;; Subroutine to check if the device exists
 ;;
 (procedure
  s;i
  ;;
  ;; Check ifsĻIy(ifc_SerDevName) exists either as a file or
  ;; as a resident device.
  ;;
  (if (<> ifc_SerDevName "")
      (if (= 1 (exists ifc_SerDevName)) ;; file exists?
	  (<> (getversion ifc_SerDevName) 0) ;; file version available?
	(if (<> (getversion (fileonly ifc_SerDevName) (resident)) 0)
					;; resident version available?
	    ((set ifc_SerDevName (fileonly ifc_SerDevName)) sŗipath
	     1) ;; true, exists
	  ))
    )
  )

 ;;
 ;; Loop until the user is satisfied
 ;;
 (while
     ((set ifc_SerDevName
	   (askfiles\siSERIAL device drivsiė	    pro_Interface ":\n"
			    "NOTE: See Help."
			    )
		    (default (if (patmatch "#?:#?" ifc_SerDevName)
				 ifc_SerDevName
			       (expandpath (cat "DEVS:" (fileonly ifc_SerDevName)))))
		    (help "    You should select thesaIŠ driver to "
			  "be used for the transport of " pro_Interface ". "
			  "You will be separately asked for the unit number.\n"
			  "    This list lists all devices in DEVS:. "
			  "Normally you would want to select "
			  "`serial.device', but "
			  "if your serial device is ROM resident, "
			  "e.g. gvpser.device, "
			  "you should enter its name manually.\n"
			  "    You can cancel this operation by giving an "
			  "empty string.")))
      (if (NOT (sĮi%-exists))
	  (if (<> ifc_SerDevName "si((message "\n"
			"   The serial device " ifc_SerDevName " does not "
			"exist. You will be prompted again for the serial "
			"device."S>iĢ1 ; ask again
	       )
	    0 ; empty string was given, do not ask again
	    )
	(
	 ;;
	 ;; remove the prefix from the file name
	 ;;
	 (if (= (pathonly (expandpath ifc_SerDevName))
		(expandpath "DEVS:siF(set ifc_SerDevName (fileonly ifc_SerDevName)))

	 (set ifc_SerUnitNumu&s$iSelect unit numbersRin ifc_SerDevName ":")
	       (default ifc_SerUnitNum)
	       (help "    Select the unit number for the devicesi*ifc_SerDevName " to use. This is 0 for thes2i,internal serial port, but might be other fors&i other serial devices."))

	      ifc_SerBaud
	      (asknumber
	       (prompt "\nGive the baud rate for the " ifc_SerDevName
		       " unit " ifc_SerUnitNum "s2i-  "\nPlease start with a low value like 9600,r2  "if you are not absolutely sure that your serials,i  "line works at higher speeds.\n")
	       (default ifc_SerBaud)
	       (help "    The baud rate MUST match the one used whilsóidialing to the IP provider.\n"
		     "    Since higher speeds may have some problems, you "
		     "should always start with some reasonably low bausi+"rate (like 9600) and then, when your setupS7Iworks, try out the higher speeds."))

	      current-bitmap
	      (bitor (if ifc_CD %00001 0)
		     (bitor (if ifc_7Wire %00010 0)
			    (bitor (if ifc_NoEOFMode %00100 0)
				   (bitor (if ifc_UseODU %01000 0)
					  (bitor (if ifc_Shared %10000 0)
						 0)))sikserial-options-bitmap
	      (askoptions
	       (prompt "\nSelect additional options to be used with the "s,ipro_Interface ":\nsäi6"\nPlease see Help for explanations for each option.")si_choices "Carrier Detect" "Hardware-handshake (CTS/RTS)"
			"No EOF-mode" "Use ODU" "Shared modes	i+default current-bitmap)
	       (help "    s¦i (CD):r0If selected, causes the " pro_Interface " to pays$i2attention to the status of the carrier detect linesi,If this isn't selected, the CD signal will bs,i
ignored.\nsi     Hardware-handshake (7Wire): si/If selected, the seven wire (or hardware, i.e.,si+TS/RTS) handshaking is used with the modem.s3i1This option is strongly recommended for high bauds.irates.\ns
i    No EOF-mode (NoEOFMode): s i(Causes " pro_Interface " not to use EOF-s/imode with the serial device.s,i0This increases the CPU load somewhat, but allowss1i#AmiTCP/IP to work with buggy serialsidevices (like the a2232)siuse ODU (UseODUs%i5Tells " pro_Interface " to use OwnDevUnit.library to si!coordinate access to the selectedss0i.unit. This option could be used in conjunctions$i4with SHARED option to allow the " pro_Interface " tosi)use a serial port opened by some one elsesishared mode (Shareds'i," pro_Interface " to open the serial port ins/i-shared mode. Using this mode allows AmiTCP/IPs.imDialer to keep serial open until the " pro_Interface
		     " opens it. This will keep the DTR signal on, andr-allows modem to hangup automatically when yous,i.stop using AmiTCP/IP. This option may also be siuseful withs+i-some \"getty\"-type of programs together withsnsJi\ns)iifc_CD (in my-serials"i      ifc_7Wire (in my-serials%i!      ifc_NoEOFMode (in my-serials)i      ifc_UseODU (in my-serials&i      ifc_Shared (in my-serials0i      my-seris	icatSiif ifc_CD        "CD s	iif ifc_7Wire     "7Wire szi¾if ifc_NoEOFMode "NoEOFMode ")
	       (if ifc_UseODU    "UseODU ")
	       (if ifc_Shared    "Shared ")
	       )
	      ) ;; set

	 (if (not (askbool
		   (prompt
		    "This is the serialsi
 you gave:sÕiŁ"\nSerial device: " ifc_SerDevName
		    "\nSerial unit: " ifc_SerUnitNum
		    "\nSerial baud rate: " ifc_SerBaud
		    "\nSerial options: " my-serial-options
		    "\n\nIs this correct?")
		   (help
		    "    Checksishown. If you do nots4iüconfirm it, all of it will be asked again.")))
	     1			; ask it all again
	   (
	    ;; store the configuration string
	    (set if-serial-config
		 (cat ifc_SerDevName " "
		      ifc_SerUnitNum " "
		      ifc_SerBaud " "
		      "0.0.0.0 "
		     s*i.options
		      "MTU=1500"	; Maximum Receive US"i  ))
	    0				; no need to asks$I# ))))
      )
   )
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 configure-serial
 (if (not pro_NeedSerial)
     (message "The interface " pro_Interface " does not need a serial device. "
	      "If you have selected a wrong interface, pleasSØie again "
	      "with another interface.")
   ((while
	((ask-serial-config)
	 (= ifc_SerDevName ""))
      0)
    (create-db-autointerfaces)u[it;;;
;;; Interface Configuration
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
s1igconfiguration-style
 ;;
 ;; Ask dialup configuration style
 ;;
 ;; parse-provider-config must be calledsiT
 ;;
 ;; This function sets following variables:
 ;;
 ;; cs-style-name - name of theSĮijstyle
 ;; cs-use-servers- ask user whether servers should be used?
 ;; pro_Interface - name of the networksIĆ
 ;; pro_NeedSerial- 0 or 1
 ;; pro_IPDynamic - 0 or 1
 ;; pro_UseBootP  - 0 or 1
 ;; pro_IPAddr    - IP address if not static (0.0.0.0 if dynamic)
 ;; pro_DialUp    - if this is an dialup configuration
 ;;
 ;; pro_Interface, pro_NeedSerial, pro_IPAddr, pro_DestIP, pro_Gateway,
 ;; pro_Netmask
 ;; are intentionally NOT set if they do not have fixed values
 ;;
 (transcript "Asking dialup configuration style.")
 (set cs-style-id
      (askchoice
   Ssi}Select one of the following configuration styles:\n"
	       "(See help for explanations.)\n")
       (help
	"    ExplanationS3i	differentSI*styles:\n"
	"\n"
	"    \"Fixed Network Connection\" should be used when you have a fixed "
	"network connection, like Ethernet, or fixed serial line.\n"
	"    \"Static SLIP\" should be used when you have been given "
	"your own IP address.\n"
	"    \"Dynamic SLIP\" is provided for "
	"dynamic SLIPSi’without BOOTP. If the dial script does "
	"not parse the IP address from the server output, you will be "
	"prompted for the IP address each time you start " @app-name ".\n"
	"    \"Dynamic SLIP with BOOTP\". This should be "
	"selected if your IP addresss3i ANDs,i«provides "
	"BOOTP service. Most terminal servers with dynamic IP addressing do "
	"have the BOOTP service. If you select to use BOOTP and there is no "
	"BOOTP service ons“iQ, you will notice the case from the "
	"error messages when starting " app-name "s}i	"s]i6configure again with some other style.\n"
	"    \"TIA sxIw\" should be used if TIA (The Internet "
	"Adapter, a commercial product for Unix) is used to provide the SLIP "
	"access.\n"
	"    \"Static PPP\" should be used when you have been given "
	"your own IP address.\n"
	"    \"Dynamic PPP\" is provided for "
	"generic dynamic PPP configuration.\n"
	"    \"Dynamic PPP with BOOTP\". This should be "
	"selected if your IP addresssIČ AND your network provides "
	"BOOTP service. Most terminal servers with dynamic IP addressing do "
	"have the BOOTP service. If you select to use BOOTP and there is no "
	"BOOTP service on your network, you will notice the case from the "
	"error messages when starting " app-name ". If this is the case, "
	"you should configure again with some other style.\n"
        )
       (choices
	"Fixed Network Connection"	; 0
	"Fixed Connection with Dynamic IP"; 1
	"Fixed Connection with BOOTP"	; 2
	"Static SLIP DialUp"		; 3
	"Dynamic SLIP DialUp"		; 4
	"Dynamic SLIP DialUp with BOOTP"; 5
	"TIA configuration DialUp"	; 6
	"Static PPP DialUp"		; 7
	"Dynamic PPP DialUp"		; 8
	"Dynamic PPP DialUp with BOOTP"	; 9
	)
Siŗ(if (not pro_DialUp)
		    (if pro_UseBootP
			2 ;; Fixed with BOOTP
		      (if pro_IPDynamic 1 ;; Fixed dynamic IP
			0) ;; Fixed without BOOTP
		      )
		  (if (= pro_Interface "slipsJIs(if (= pro_IPAddr "192.0.2.1")
			  6	;; TIA
			(if (not pro_IPDynamic)
			    3	;; static SLIP
			  (if pro_UseBootP
			      5	;; Dynamic SLIP with BOOTP
			    4	;; Dynamic SLIP without BOOTP
			    )))
		    (if (not pro_IPDynamic)
			7	;; static PPP
		      (if pro_UseBootP
			  9	;; Dynamic PPP with BOOTP
			8	;; Dynamic PPP without BOOTP
			))
		    )))
       )S“I£set style options according to the user's choice
 ;;
 (select cs-style-id
	 ;; (0, Fixed Network Connection)
	 (set
	  cs-style-name "Fixed Network Connection"
	  pro_DialUp 0
;;	  pro_Interface ""	;; use current
;;	  pro_NeedSerial 0	;; use current
;;	  pro_IPAddr ""		;; use current
	  pro_IPDynamic 0
	  pro_UseBootP 0
	  cs-use-servers 1
	  )
	 ;; (1, Fixed Network with Dynamic IP)
	 (set
	  cs-style-name "Fixed CS
KIĢwith Dynamic IP"
	  pro_DialUp 0
;;	  pro_Interface ""	;; use current
;;	  pro_NeedSerial 0	;; use current
	  pro_IPAddr "0.0.0.0"	;; dynamic
	  pro_IPDynamic 1
	  pro_UseBootP 0
	  cs-use-servers 1
	  )
	 ;; (2, Fixed Connection with BOOTP)
	 (set
	  cs-style-name "Fixed Connection with BOOTP"
	  pro_DialUp 0
;;	  pro_Interface ""	;; use current
;;	  pro_NeedSerial 0	;; use current
	  pro_IPAddr "0.0.0.0"	;; dynamic
	  pro_IPDynamic 1
	  pro_UseBootP 1
	  cs-use-servers 1
	  )
	 ;; (3, Static SLIP)
	 (set
	  cs-style-name "Static SLIP"
	  pro_DialUp 1
	  pro_Interface "slip"
	  pro_NeedSerial 1
;;	  pro_IPAddr ""		;; remember old address
	  pro_IPDynamic 0
	  pro_UseBootP 0
	  cs-use-servers 0
	  )
	 ;; (4, Dynamic SLIP)
	 (set
	  cs-style-name "Dynamic SLIP"
	  pro_DialUp 1
	  pro_Interface "slip"
	  pro_NeedSerial 1
	  pro_IPAddr "0.0.0.0"		;; default IP address (not known)
	  pro_IPDynamic 1
	  pro_UseBootP 0
	  cs-use-servers 0
	  )
	 ;; (5, Dynamic SLIP with BOOTP)
	 (set
	  cs-style-name "Dynamic SLIP with BOOTP"
	  pro_DialUp 1
	  pro_Interface "slip"
	  pro_NeedSerial 1
	  pro_IPAddr "0.0.0.0"		;; default IP address (not known)
	  pro_IPDynamic 1
	  pro_UseBootP 1
	  cs-use-servers 0
	  )
	 ;; (6, TIA configuration)
	 (set
	  cs-style-name "TIA configuration"
	  pro_DialUp 1
	  pro_Interface "slip"
	  pro_NeedSerial 1
	  pro_IPAddr "192.0.2.1"	;;; The dummy IP for TIA
	  pro_IPDynamic 0
	  pro_UseBootP 0
	  cs-use-servers 0
	  )
	 ;; (7, Static PPP)
	 (set
	  cs-style-name "Static PPP"
	  pro_DialUp 1
	  pro_Interface "ppp"
	  pro_NeedSerial 1
;;	  pro_IPAddr ""		;; remember old address
	  pro_IPDynamic 0
	  pro_UseBootP 0
	  cs-use-servers 0
	  )
	 ;; (8, Dynamic PPP)
	 (set
	  cs-style-name "Dynamic PPP"
	  pro_DialUp 1
	  pro_Interface "ppp"
	  pro_NeedSerial 1
	  pro_IPAddr "0.0.0.0"		;; default IP address (not known)
	  pro_IPDynamic 1
	  pro_UseBootP 0
	  cs-use-servers 0
	  )
	 ;; (9, Dynamic PPP with BOOTP)
	 (set
	  cs-style-name "Dynamic PPP with BOOTP"
	  pro_DialUp 1
	  pro_Interface "ppp"
	  pro_NeedSerial 1
	  pro_IPAddr "0.0.0.0"		;; default IP address (not known)
	  pro_IPDynamic 1
	  pro_UseBootP 1
	  cs-use-servers 0
	  )
	 )
 (set ifc_Name pro_Interface) ;; direct mapping this time
 )
uTsEIP
;; parse-provider-config has to be called before this
;;
;; The provider configuration is stored in db/Provider.conf
;; This procedure edits this configuration.
;;
;; The options we support are:
;;
;; pro_Interface  - slip or ppp
;; pro_IPDynamic - 0 or 1
;; pro_UseBootP - 0 or 1
;; pro_IPAddr - IP address if not static (0.0.0.0 if dynamic)
;;
;; pro_NSDynamic - YES|NO
;; pro_MTU       - 72 to 1500
;; pro_Phone     - provider phone number
;; pro_HdrCompress - YES|NO|AUTO
;; pro_PAPHostId     -
;; pro_PAPPassword   -
;; pro_CHAPHisHostId -
;; pro_CHAPPassword  -
;; pro_CHAPHostId    -
si7provider-config
 (transcript "Asking PROVIDER options."sti¹Loop until the user is satisfied
 ;;
 (while
     ((ask-configuration-style)
      (not
       (if pro_DialUp
	   (ask-dialup-provider-config)
	 (ask-fixed-provider-config))))
   )
 )

sjIžask-dialup-provider-config
 ;;
 ;; Confirm/update DialUp Provider options.
 ;; We return true if the user is satisfied with the values.
 ;;
 ;; pro_Name, pro_DialUp, pro_Interface, pro_NeedSerial, pro_IPDynamic and
 ;; pro_UseBootP are already set.
 ;;
 ;; PAP & CHAP options are not supported currently.
 ;;
 ;; We clear pro_DestIP, pro_Gateway and pro_Netmask.
 ;;
 (transcript "Asking DIALUP PROVIDER options.")

 (set
  pro_IPAddr
  (if pro_IPDynamic "0.0.0.0"
    (if-ask-address))
      
  pro_NSDynamic
si®   (prompt "\nIs your name server configuration static or are the"
	   " name servers configured dynamically?")
   (default pro_NSDynamic)
   (choices "Static" "Dynamic")
   sēiDIf the addresses of the name servers are known in advance"
	 " then soi^is static. In this case you will "
	 "be prompted for the name server addresses during the "
	SIation phase.\n"
	 "    If the addresses of the name servers may be different "
	 "on different logins, then the configuration is dynamic. "
	 "In this case the name servers must be configured by the "
	 "dial script or they must be gotten via BOOTP.\n"
	 )
   )
  pro_MTU
  (asknumber
 sit"\nGive the Maximum Transfer Unit (MTU) for the "
	   pro_Interface ":\n")
   (range 72 1500)
   (default pro_MTU)
 s¼iMThis option affects only outgoing data. "
	 "Maximum Receive Unit size is notSSI;ble.\n"
	 "    Smaller values give better interactive response "
	 "during file transfers, while larger values give better "
	 "throughput."
	 ))
  pro_Phone
  (askstring
   (prompt "\nGive the phone number for your IP provider:\n"
	   "Please enter JUST numbers, or your modem will not accept "
	   "the number.")
sUi®pro_Phone)
   (help "   The phone number should countain JUST numbers!\n"))
  
  pro_HdrCompress
  (select
   (askchoice
    (prompt "\nSelect IP header compression mode:")
 s!iX(if (= pro_HdrCompress "YES")
		 0
	       (if (= pro_HdrCompress "NO")
		   1
		 2)))
 S	SI„YES"
	     "NO"
	     "AUTO")
    (help "    If you select \"YES\", header "
	  "compression is allways applied.\n"
	  "    The option \"NO\", header "
	  "compression is not applied to outgoing data, but if "
	  "incoming headers are compressed they are still "
	  "uncompressed.\n"
	  "    In \"AUTO\" mode header "
	  "compression is off by default, but after a "
	  "compressed packet is received, outgoing headers "
	  "are compressed as well.\n"))
   "YES" "NO" "AUTO")
  ;;
  ;; DialUp configuration does not use these
  ;;
  pro_DestIP ""
  pro_Gateway ""
  pro_Netmask ""
  ;;
  ;; Add PAP & CHAP support into the official release
  ;;
  pro_PAPHostId ""
  pro_PAPPassword ""
  pro_CHAPHisHostId ""
  pro_CHAPPassword ""
  pro_CHAPHostId ""
  ) ;; set

 (askbool
  (prompt
   "This is the configuration you gave "
   "for the provider configuration " pro_Name ":\n"
   "\nInterface: " pro_Interface
   "\nIP Address: " (if pro_IPDynamic "<dynamic>" pro_IPAddr)
   "\nUseBootP: " (if pro_UseBootP "YES" "NO")
   "\nDynamic Name Servers: " (if pro_NSDynamic "YES" "NO")
   "\nMTU: " pro_MTU
   "\nPhone number: " pro_Phone
   "\nTCP header compression: " pro_HdrCompress
   "\n\nIs this correct?")
  (help
   "    Check the information shown. If you do not "
   "confirm it, all of it will be asked again."))
 )

(procedure
 ask-fixed-provider-config
 ;;
 ;; Confirm/update Fixed Provider options.
 ;; We return true if the user is satisfied with the values.
 ;;
 ;; pro_Name, pro_DialUp, pro_IPDynamic, pro_UseBootP are already set.
 ;;
 ;; PAP & CHAP options are not supported currently.
 ;;
 ;; pro_DestIP will not be asked
 ;;
 (transcript "Asking FIXED PROVIDER options.")

 pro_Interface
si)interface
  ;;
  ;; Ask if want to changesgiif already set
  ;;
  (set do-ask-if
       (if (= pro_Interface "")
	   1
	 (not (askbool 
	       (prompt "Do you want to keep the currentsi?\n\n"
		       "CurrentS"iÖis: \"" pro_Interface "\".")
	       (help "The current interface name will be kept if you do not want "
		     "to change it.")))))

  (if do-ask-if
      ;;
      ;; Sets pro_Interface if one is selected
      ;;s(i1
       if-type-choice
       ;;
       ;; SelectsXitype
       ;;
       (askchoice
	(prompt (cat "Select the network interface type to be used:"))
	(help "    You should select your network interfaces/i+type from the given choices. If your devices/itype issi,not listed select some other (which matches si"closest to your device) and alter si+the configuration (and db/interfaces file) SsI[by hand.\n")
	(choices
	 "SLIP/PPP"		; 0
	 "X.25"		; 1
	 "Ethernet"		; 2
	 "Arcnet"		; 3
	 "GGBus+ Ethernet"	; 4
	 "PLIP/Liana"	; 5
	 )
	(default 0))
       ;;
       ;; SLIP/PPP needs serial
       ;;
       pro_NeedSerial (= if-type-choice 0)
       pro_MTU (if (= if-type-choice 0) 576 0) ;; default MTU

       ;;
       ;; Select the specificsųi[ of the type
       ;;
       if-choice
       (askchoice
	(prompt (cat "Select the networks$i9to be used:"))
	(help "    You should select your networkSüI
"
	      "from the given choices. If your device is "
	      "not listed select some other (which matches "
	      "closest to your device) and alter "
	      "the configuration (and db/interfaces file) "
	      "by hand.\n")
	(select if-type-choice
		(			; type 0 (SLIP/PPP)
		 (choices "SLIP"		; 0
			  "PPP"			; 1
			  ))
		(			; type 1 (AX.25)
		 (choices "axdm"		; 0
			  ))
		(			; type 2 (Ethernet)
		 (choices "CBM A2065"		; 0
			  "Hydra Ethernet"	; 1
			  "ASDG EB920"		; 2
			  "Village Tronic Ariadne" ; 3
			  "Ameristar a4066" 	; 4
			  "QuickNet"		; 5
			  )
		 (default 3))
		(			; type 3 (Arcnet)
		 (choices "CBM A2060"		; 0
			  ))
		(			; type 4 (GGBus+ Ethernet)
		 (choices "3COM 3C503"		; 0
			  "NE1000" 		; 1
			  "NE2000" 		; 2
			  "WD80x3"		; 3
			  )
		 (default 2))
		(			; type 5 (PLIP/Liana)
		 (choices "PLIP unit 0"			; 0
			  "PLIP unit 1"			; 1
			  "Liana unit 0"		; 2
			  "Liana unit 1"		; 3
			  "Ariadne Liana unit 0"	; 4
			  "Ariadne Liana unit 1"	; 5
			  ))
		))
       ;;
       ;; Set thSio name according to the selection
       ;;
       ;; The names int the table must match the ones defined in db/Sxij
       ;;
       pro_Interface
       (select (+ (* if-type-choice 8) if-choice)
					; type 0 (SLIP/PPP)SÓIkslip"	; (0) 
	       "ppp"	; (1)
	       ""		; (2)
	       ""		; (3)
	       ""		; (4)
	       ""		; (5)
	       ""		; (6)
	       ""		; (7)
					; type 1 (AX.25)
	       "ax25"	; (0) 
	       ""		; (1)
	       ""		; (2)
	       ""		; (3)
	       ""		; (4)
	       ""		; (5)
	       ""		; (6)
	       ""		; (7)
					; type 2 (Ethernet)
	       "a2065"	; (0) 
	       "hydra"	; (1)
	       "eb920"	; (2)
	       "ariadne"	; (3)
	       "a4066"	; (4)
	       "quicknet"	; (5)
	       "wd80xx"	; (6)
	       ""		; (7)
					; type 3 (Arcnet)
	       "a2060"	; (0) 
	       ""		; (1)
	       ""		; (2)
	       ""		; (3)
	       ""		; (4)
	       ""		; (5)
	       ""		; (6)
	       ""		; (7)
					; type 4 (GGBus+ Ethernet)
	       "gg_3c503"	; (0) 
	       "gg_ne1000"	; (1)
	       "gg_ne2000"	; (2)
	       "gg_smc"	; (3)
	       ""		; (4)
	       ""		; (5)
	       ""		; (6)
	       ""		; (7)
					; type 5 (Village Tronic Liana)
	       "plip0"	; (0) 
	       "plip1"	; (1)
	       "liana0"	; (2)
	       "liana1"	; (3)
	       "ariadneliana0" ; (4)
	       "ariadneliana1" ; (5)
	       ""		; (6)
	       ""		; (7)
	       ))))
 
sIiĶ  if-ask-gateway ;;; Ask the default gateway address
  ;;
  ;; Returns the gateway address
  ;;
  (set ::ask-ip-prompt 
       (cat
	"Enter the IP address of the default gateway:"
	"\n\n(For point-to-pointsÅILs, "
	"the default gateway address will also be used as the "
	"interface destination address.)"
	)
       ::ask-ip-help
       (cat
	"    All network packets for destinations for which "
	"there is no defined route, are sent to the default "
	"gateway, which (hopefully) can send them towards "
	"the destination host.\n"
	"    ThesŻI (instead of a name) is needed, "
	"because the name may not be resolved without the "
	"gateway, if the name server is not "
	"in your local network.")
       ::ask-ip-need 0
       ::ask-ip-default pro_Gateway
       )
  (ask-ip-address))
 
 (procedure
  s4ij
  ;;
  ;; Returns the netmask
  ;;
  (set ::ask-ip-prompt
       (cat "Give netmask of the network on thes"i.
	    pro_Interface ".\n"
	    "Address of theS£Iįis "
	    (if pro_IPDynamic
		"<dynamic>"
	      pro_IPAddr)
	    ".\n")
       ::ask-ip-help 
       (cat "    Netmask is a dot separated string of four "
	    "decimal numbers (similar to an internet address), "
	    "which specifies which bits of the host's IP address "
	    "are used to identify the network "
	    "(the network address).\n"
	    "    For example, \"255.255.255.0\" "
	    "is a possible netmask.\n"
	    "    The netmask must be the same for all the "
	    "sIiconnected to the same network.\n"
	    "    If you do NOT know the netmask, then leave "
	    "it empty, a default value will be computed from "
	    "yourSi`'s IP address. This is correct only if "
	    "the network is not divided into subnets.")
      sgineed 0
       ::ask-ip-default pro_Netmask
       )
  (ask-ip-address))
 ;;
 ;; Sets:
 ;; pro_NeedSerial
 ;; pro_Interface
 (if-asksęI)

 (set
  pro_IPAddr (if pro_IPDynamic "0.0.0.0"
	       (if-ask-address))
  pro_Netmask (if-ask-netmask)
  pro_Gateway (if-ask-gateway)
  pro_DestIP  ""
  
  pro_NSDynamic
  (askchoice
   (prompt "\nIs your name server configuration static or are the"
	   " name serversS<IÆdynamically?")
   (default pro_NSDynamic)
   (choices "Static" "Dynamic")
   (help "    If the addresses of the name servers are known in advance"
	 " then the configuration is static. In this case you will "
	 "be prompted for the name server addresses during the "
	 "configuration phase.\n"
	 "    If the addresses of the name servers may be different "
	 "on different logins, then the configuration is dynamic. "
	 "In this caSŹixservers must be configured by the "
	 "dial script or they must be gotten via BOOTP.\n"
	 )
   )
  pro_MTU
  (asknumber
sµi(Give the Maximum Transfer Unit (MTU) fors0i"
	   "\"" pro_Interface "\":\n\n"
	   "0 represents the interface default (maximum).")
   (range 0 1500)
   (default pro_MTU)
SqI	This option affects only outgoing data. "
	 "Maximum Receive Unit size is not configurable.\n"
	 "    Smaller values give better interactive response "
	 "during file transfers, while larger values give better "
	 "throughput."
	 "For other than serial device usingSEI_s you should "
	 "select 0, which causes the hardware default MTU to be used."
	 ))
  pro_Phone ""
  pro_HdrCompress
  (if (not pro_NeedSerial) ""
    (select
     (askchoice
      (prompt "\nSelect IP header compression mode:")
      (default (if (= pro_HdrCompress "YES")
		   0
		 (if (= pro_HdrCompress "NO")
		     1
		   2)))
      (choices "YESs7iNOS6i]"AUTO")
      (help "    If you select \"YES\", header "
	    "compression is allways appliedi­"    The option \"NO\", header "
	    "compression is not applied to outgoing data, but if "
	    "incoming headers are compressed they are still "
	    "uncompressed.\n"
	 sDiß\"AUTO\" mode header "
	    "compression is off by default, but after a "
	    "compressed packet is received, outgoing headers "
	    "are compressed as well.\n"))
     "YES" "NO" "AUTO"))

  ;;
  ;; Add PAP & CHAP supportSęiofficial release
  ;;
  pro_PAPHostId ""
  pro_PAPPassword ""
  pro_CHAPHisHostId ""
  pro_CHAPPassword ""
  pro_CHAPHostId ""
  ) ;; set

 (askbool
SnI   "This is the configuration you gave "
   "for the provider configuration " pro_Name ":\n"
   "\nInterface: " pro_Interface
   "\nIP Address: " (if pro_IPDynamic "<dynamic>" pro_IPAddr)
   "\nNetmask: " (if (= pro_Netmask "") "<default>" pro_Netmask)
   "\nGateway Address: " pro_Gateway
   "\nUseBootP: " (if pro_UseBootP "YES" "NO")
   "\nDynamic Name Servers: " (if pro_NSDynamic "YES" "NO")
   "\nMTU: " (if (= pro_MTU 0) "<default>" pro_MTU)
   (if pro_NeedSerial (cat "\nTCP header compression: " pro_HdrCompress))
   "\n\nIs this correct?")
  (help
   "    Check the information shown. If you do not "
   "confirm it, all of it will be asked again."))
 )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Ask for the IP address of this host
;;
(procedure
 if-ask-address
 (if (= pro_IPAddr "0.0.0.0")
     (set pro_IPAddr ""))
 (set ::ask-ip-prompt
      (cat "IP address for the interface " pro_Interface ".\n")
      ::ask-ip-help
      (cat "    IP address must be configured now for a static configurasIdWARNING: Only ONE of the possible values is legal, random IP "
	   "addresses must NOT "
	   "be used, it might cause harm for you and your IP provider.\n\n"
	   "    If you have no connection to the global "
	   "Internet and are configuring a private network, "
	   "you can select your IP addresses from following "
	   "ranges: (see RFC1597)\n\n"
	   "10.0.0.0 - 10.255.255.255\n"
	   "172.16.0.0 - 172.31.255.255\n"
	   "192.168.0.0 - 192.168.255.255\n\n"
	   "NOTE: The addresses at the end of the ranges are "
	   "NOT usable IP addresses for a host! So select your "
	   "address from INSIDE the range (fSVI-: "
	   "10.1.1.1)."	   )
      ::ask-ip-need 1
      ::ask-ip-default pro_IPAddr
      pro_IPAddr (ask-ip-address))
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 create-db-autointerfaces
 ;;
 (textfile (dest (tackon conf-dir "autointerfaces"))
	   (append "# This file is generated automatically by 'Config AmiTCP'\n")
	   (append
	    (cat "slip DEV=DEVS:Networks/aslip.device UNIT=0 DoOffline "
		 "ConfigFileName=ENV:Sana2/aslip0.config "
		 "ConfigFileContents=\"" if-serial-config "\"\n"))
	   (append
	    (cat "ppp DEV=DEVS:Networks/ppp.device UNIT=0 DoOffline "
		 "ConfigFileName=ENV:Sana2/ppp0.config "
		 "ConfigFileContents=\"" if-serial-config "\"\n"))
	   )
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; s½i configuration
;;uQi;;
s²i$nameservers ;;; Ask addresses to thes(i
 ;;
 (set name-server-list ""
      name-server-text-list "")
 (while
     (set ::ask-ip-prompt
	  (cat "Enter the IP addresses of ts{i!s (one at a time). "
	       "Thes	iõs will be searched in the given order.\n"
	       (if name-server-text-list
		   ("\nIncluded name servers are: %s\n"
		    name-server-text-list)))
	  ::ask-ip-help
	  (cat "    A name server is used to resolve host "
	       "names to internetsji×. This allows you "
	       "to use symbolic names for the hosts instead "
	       "of internet addresses.\n"
	       "    In Unix systems the name server addresses are "
	       "usually stored into the file `/etc/saI`.\n")
	  ::ask-ip-need 0
	  ::ask-ip-default ""
	  name-server-addr (ask-ip-address))
   (set name-server-list (cat name-server-list
			      "NAMESERVER " name-server-addr "\n")
	name-server-text-list (cat name-server-text-list "\n"
				   name-server-addr)))
 uSi;;
s,si

 ;;
 (setsi ""
      text-SėIx "")
 (while
     (set domain
	  (askstring
	   (prompt
	    "Give domain names (one at a time) to search.\n"
	    "Press proceed after you have given each domain.\n"
	    "Give empty domain after you have finished.\n"
	    (if text-domain-list
		(cat "\nIncluded domains are:"
		    text-domain-list)))
	  (help
	   net-setup-help
	   "    In many environments more than one search domain "
	   "is needed for name resolution.\n"
	   "    For example, most of computers in the Helsinki "
	   "University of Technology are under single domain: "
	   "\"hut.fi\", so the full name of computer named "
	   "\"vipu\" would be \"vipu.hut.fi\". If the default "
	   "domain is \"hut.fi\", then this computer can be "
	   "referred without the domain part of the name (just "
	   "\"vipu\"). However, the computer science department "
	   "has its own domain \"cs.hut.fi\". When computers of "
SÄI÷"the computer science department "
	   "are referred, the full name must be supplied, e.g. "
	   "\"colossus.cs.hut.fi\". This can be avoided by "
	   "providing \"cs.hut.fi\" as a secondary search domain. "
	   "The domains are searched in the given order. It is "
	   "fastest to give the most used domain first.\n"
	   "    In Unix systems the domain names are "
	   "usually stored into the file `/etc/resolv.conf`.\n")
	  (default "")))
   (set domain-list ("%sDOMAIN %s\n" domain-list domain)
	text-domain-list (cat text-domain-list "\n" domain)
	default-domain ""))
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 ask-resolv-conf
 ;;
 ;; Show existing information first and ask if should change
 ;;
 (if
S6iżexists (tackon conf-dir "resolv.conf"))
	 (
	  (textfile (dest "ENV:resolv.conf.tmp")
		    (include (tackon conf-dir "resolv.conf"))
		    (safe))
	  (set tmp-resolv-conf (getenv "resolv.conf.tmp"))
	  (askbool (prompt
		    "Your current name resolverSViQis:\n\n"
		    tmp-resolv-conf
		    "\nDo you want to change it?")
		   (help
		S$Ióyou select \"Yes\" you will be asked for "
		    "name server addresses and search domain names.")
		   ))
       1)
     (
      (ask-nameservers)
      (ask-domains)
      (textfile (dest (tackon conf-dir "resolv.conf"))
		(append
		 (if name-server-list
		     (cat "; Name servers\n" name-server-list)))
		(append
		 (if domain-list
		     (cat "; Domain names\n" domain-list))))))
 )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 store-default-user-name
 ;;
 ;; Store default user name into ENV:LOGNAME (ENVARC: too)
 ;;
 ;; user name is passed in default-user-name
 ;;
 (transcript "Storing default user name " default-user-name
	     " to ENV:LOGNAME.")
 (textfile (dest "ENVARC:LOGNAME")
	   (append ::user-name))
 (textfile (dest "ENV:LOGNAME")
	   (append ::user-name))
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 ;;
 ;; Check if user exists in the user database
 ;;
 ;; takes the user name in ::user-name
 ;;
 does-user-exist
 (if (run (cat "search " (tackon conf-dir "passwd") " \"" ::user-name "|\" NONUM ")
	  (safe))
     0
   1)
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 ;;
 ;; Add a new user intoS±Ipasswd
 ;;
 add-new-user
 (if (= anu::setdefaults 0)
     (set
      anu::passwd (tackon conf-dir "passwd")
      anu::passwd-new (cat anu::passwd ".new")
      anu::passwd-old (cat anu::passwd ".old")
;;;;      anu::tempfile "t:run-the-password"
      anu::helptext (cat "    You must give an login name, user ID, group ID "
			 "real name and home directory for each user.\n")
      anu::setdefaults 1
      anu::username (cat default-user-name)
      anu::UID 200
      anu::GID 100
      anu::realname ""
      anu::homedir "HOME:"
      anu::shell "shell"))
 (while
     ((set anu::username
	   (askstring
	    (default anu::username)sqi'Enter the login name of the new user:\nSIGanu::helptext
		  "    The login name consists of lowercase letters a-z "
		  "and numbers.  Its recommended maximum length is 8 "
		  "characters.\n"
		  "    Examples of acceptable login names are `ppessi' "
		  "and `an345'.\n"
		  "    Give an empty name to bypass this operation.")))
      (set ::user-name anu::username)
sKiR<> ::user-name "")
	  (if (does-user-exist)
	      ((set anu::username "")
	      si. "User " ::user-name " already exists.\n"
			"s7io add another usersßiµ "")))
	    0)
	0)))
 (if (<> anu::username "")
     (
      (set anu::UID
	   (asknumber
	    (default anu::UID)
	    (prompt (cat "Enter the user ID of the user " anu::username ":s$i(help anu::helptext
		  "    The user ID is a numeric unique identifier for each "
		  "user. "
		  "It is a number between 200 - 32767 for ordinary users.\n"sĒi6(set anu::GID
	   (asknumber
	    (default anu::GID)
	S5iJ(cat "Enter the primary group ID of the user "
			 anu::username ":\n"))
	sŁianu::helptext
		  "    The group ID is a numeric identifier of groups. "
		  "Each user has a primary group, which is usually 100, "
		  "group \"users\".\n"))sWi>et anu::realname
	   (askstring
	    (default anu::realname)
	siF(cat "Enter the real (full) name of the user " anu::username ":\n"))
	s®IÄanu::helptext
		  "    The real name can contain any characters except "
		  "comma (`,'), colon (`:') or bar (`|').")))
      (set anu::homedir
	   (askdir
	    (default anu::homedir)
	    (prompt (cat "Give the home directory of the user " anu::username ":\n"))
	    (help anu::helptext
		  "    When user logs in, the current directory is changed to"
		  "her home directory.  Also, the finger information (.plan"
		  "and .project) is retrieved from the home directory.")
	    (newpath)))
      (set anu::shell
	   "shell")
;      (askstring
;       (default anu::shell)
;       (prompt (cat "Enter the name of command interpreter for the user "
;		    anu::username ":\n"))
;       (help anu::helptext
;sŌI The command interpreter value can be either "
;	     "`shell' or `cli'.")))
      (set anu::passwd-entry
	   (cat anu::username "||" anu::UID "|" anu::GID "|"
		anu::realname "|" anu::homedir "|" anu::shell "\n"))
      (if (askbool
	   (prompt (cat "Are you sure you want to add following user:\n\n"
			"Login name: " anu::username "\n"
			"User ID: " anu::UID "\n"
			"Group ID: " anu::GID "\n"
			"Real name: " anu::realname "\n"
			"Home directory: " anu::homedir "\n"
;			"Shell: " anu::shell "\n"
			))
	   (choices (cat "Add " anu::username) (cat "Skip " anu::username))
	   (help "You can still skip creating the new user."))
	  (s i/nu::passwd-new)
		     (include anu::passwd)
		SęIāanu::passwd-entry))
	   (copyfiles (source anu::passwd)
		      (dest conf-dir)
		      (newname "passwd.old")
		      (optional "askuser"))
	   (copyfiles (source anu::passwd-new)
		      (dest conf-dir)
		      (newname "passwd")
		      (optional "askuser"))
;;;;       (textfile (dest anu::tempfile)
;;;;		(append (cat
;;;;			 "failat 5000\n"
;;;;			 "avail flush >nil:\n"
;;;;			 "avail flush >nil:\n"
;;;;			 (tackon bin-dir "login") " " anu::username "\n"
;;;;			 (tackon bins4iĒ" anu::username "\n"
;;;;			 "endshell\n"))
;;;;		(safe))
;;;;       (run (cat "newshell from " anu::tempfile))
	   (set anu::username ""
		anu::UID (+ anu::UID 1)
		anu::realname "")
	   1))
      )u`ss0i(sk for the default user
 ;;
 ask-default¦SDi	
      adssvihumask "022"
      default-user-name (if (exists "ENV:LOGNAME")
			    (getenv "LOGNAME")
			  "")
      s	idefault-user-u"s	idefault-user-sidefault user namesi"    Default user name is tsiof the user that "
		  "is logged in automatically at AmiTCP/IP startup. "
		  "Networking programs can use this name when they need to "
		  "find ths#I of the current user.\n"
		  "    The default user name is stored in "
		  "ENV:LOGNAME, which is used by the login command "
		  "in the AmiTCP:bin/startnet to set the default user name."
		  "    AmiTCP/IP can handle currently only one user "
		  "at a time. "
		  s	idefault-user-i/= ::user-name "")
	  1 ;; ask again
	(if (NOT (si)
	  SĖIĀ
	      "\nYou will now be prompted for user information.")
	     (NOT (add-new-user)))))))
 (store-default-user-name)
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; (Re-)configure AmiTCP/IP
;;;
(procedure
 configure-modem
 (if (not pro_DialUp)
     (message "Your IP setup does not need a modem. If this is not true, select "
	      "one of the non-fixed configuration styles.")
   ((set mod_InitString
	SHi	  (prompt
	  SVIČmodem initialization string, including the leading \"AT\":")
	  (help "    Modem initialization string should bring the modem to the "
		"state compatible with configured serial options. For example, "
		"if you specify CTS/RTS flow control, you should specify the "
		"command \"&K3\" in the initialization string (this may vary "
		"from modem to modem).\n"
		"    Please consult your modem documentation to find correct "
		"initialization string.\n")
	S-I(if (exists "ENV:ModemInitString")
		       (getenv "ModemInitString")
		     "AT&F&C1&D2")))
	 mod_DialPrefix
	 (askstring
	  (prompt
	   "Give the modem dial prefix, including the leading \"AT\":")
	  (help "    Modem dial prefix specifies whether your phone line has "
		"pulse dial (ATDP) or tone dial (ATDT). Also, if your phone line "
		"is not directly connected to the public telephone network, "
		"you might need to add leading 0 and then wait for a dialtone "
		"(ATDT0w).\n")
	  (default (if (exists "ENV:ModemDialPrefix")
		       (getenv "ModemDialPrefix")
		     "ATDT")))
	 )
    ;; store the values to ENVARC: AND ENV:
    S!i:"ENVARC:ModemInitString")
	      (append mod_InitString))
SÉiÜ"ENV:ModemInitString")
	      (append mod_InitString))
    (textfile (dest "ENVARC:ModemDialPrefix")
	      (append mod_DialPrefix))
    (textfile (dest "ENV:ModemDialPrefix")
	      (append mod_DialPrefix))
    ))
 )


s?igconfigure-provider
 (ask-provider-config)
 (save-provider-config))

(procedure
 save-as-provider-configsi$(set save-pro-file
	   (askfile
	   sŗi6Give a name for the backup provider configuration:")
	S¦I-This display provides preconfigured IP provider entries. "
		  "You should type a new name into the file name box.\n")
	    (default (expandpath "AmiTCP:Providers"))))
      (<> (expandpath "AmiTCP:Providers") (expandpath (pathonly save-pro-file))))
   0)
 (set save-file 1)
 (if (exists save-pro-filesŚisave-file
	  (askbool
	s$iXThe file \"" save-pro-file "\" already exists.\n"
		   "Do you want to overwrite it?")
	S^iOverwriting an existings	i~makes it "
		 "unavailable later.\n"))))
 (if save-file
     (textfile (dest save-pro-file)
	       (include pro_FileName))))
sOi)select-provider-config
 (set temp-pro-filsifilsUithe provider to use:sŻi¤ "   This display provides preconfigured IP provider entries. "
	     "If your provider is listed here, you will not need to configure "
	     "IP provider specificsbiÕ.\n")
       (default (expandpath "AmiTCP:Providers/Other"))))
 (if (<> temp-pro-file "")
     (if (= (exists temp-pro-file) 1)
	 ((if (exists pro_FileName)
	      (if (askbool (prompt "Do you want to save the olds¼i "
				   "before replacing its|i”new one?")
			   (help "   The new provider information will "
				 "overwrite the existing information. It is "
				 "recommended that you save the old "
				 "sMI before replacing it with a "
				 "new one."))
		  (save-as-provider-config)))
	  ((textfile (dest pro_FileName)
		     (include temp-pro-file))
	   (parse-provider-config)
	   (message
	    "\n   Parameters in following dialogs show the values "
	    "defined in the "
	    SĄi$provider profile.  If you agree withsŠiX"
	    "options, just \"Proceed\" in each dialog.\n")
	   (configure-provider)
	   )
	  Sµiēmessage "\nThe selected file \"" temp-pro-file "\" is not a file."))
   ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(procedure
 ask-run-servers ;;; Ask if servers programs should be run
 (ifSzi

     (sets»I
	  (askbool
	   (prompt "\nDo you intend to run server programs?\n\n"
		   "If you select \"Yes\", the Internet `Super Server' "
		   "inetd will be started at the " @app-name " startup. "
		   "The loop-back interface (\"lo0\") will also be "
		   "configured.\n")
	   (help "    Inetd is the Internet `Super Server', which "
		 "listens for connections on behalf of other "
		 "servers. When a connection request for a port, "
		 "for which Inetd is configured to listen, arrives "
		 "Inetd accepts the connections and starts the "
		 "server in question. The inetd is thus essential for "
		 "most of the server programs.\n"
		 "    The loop-back interface allows you to test the server "
		 "programs locally.\n"
		 "    Refer to the documentation for more "
		 "Sśion server configuration.")))))
uQs%sås¼IF
 ;;
 ;; Create the network startup-script (AmiTCP:bin/startnet)
 ;;
 (textfile
  (dest (tackon bin-dir "startnet"))
  (append
   (cat
    ".key DEBUG/S,SRV/S\n"
    ".bra {\n"
    ".ket }\n"
    ";\n"
    "; \"SRV\" if servers are used, _nothing_ otherwise\n"
    ".def SRV   " (if cs-use-servers "SRV") "\n"
    ";\n"
    ";si9 4.3 startnet script\n"
    ";\n"
    "; Copyright © 1996S½iGroup,\n"
    ";SIéNSDi - Network Solutions Development Inc., Finland\n"
    ";                  All rights reserved.\n"
    ";\n"
    "; *NOTE*  YOU SHOULD NOT NEED TO EDIT ANYTHING BELOW. IF YOU NEED TO START\n"
    "; *NOTE*  UTILITIES, DO IT IN THE AmiTCP:db/User-Startnet.\n"
    ";\n"
    "; Set the failat level so that the errors can be handled by the script\n"
    "FailAt 21\n"
    "\n"
    "if not exists AmiTCP:db/provider.conf\n"
    "  echo AmiTCP/IP is not configured\n"
    "  echo Starting cSiGtool\n"
    "  run >nil: <nil: installer "AmiTCP:Config AmiTCP" APPNAMEsOiMINUSER AVERAGE\n"
    "  quit 20\n"
    "endif\n"
    "\n"
    "version bsdsocket.library >nil:\n"
    "if not warn \n"
    "  echoSićrunning\n"
    "  echo Exiting...\n"
    "  quit 20\n"
    "endif\n"
    "run >nil: <nil: AmiTCP:AmiTCP {DEBUG}\n"
    "WaitForPort AMITCP\n"
    "If NOT Warn\n"
    "  ; Log in with the default user name (ENV:LOGNAME)\n"
    "s¦Iwlogin -f\n"
    "  ; Configure AmiTCP\n"
    "  AmiTCP:bin/bootpconfig {DEBUG}\n"
    "  If NOT Warn\n"
    "    ;\n"
    "    ; Mount TCP:\n"
    "    ;\n"
    "    Assign TCP: Exists >NIL:\n"
    "    IF Warn\n"
    "      Mount TCP: from AmiTCP:devs/Inet-Mountlist\n"
    "    EndIf\n"
    "    ;\n"
    "    ; Start inetd if requested\n"
    "    ;\n"
    "    If NOT X EQ \"X{SRV}\"\n"
    "      If X EQ \"X{DEBUG}\"\n"
    "        Run <NIL: >NIL: AmiTCP:bin/inetd\n"
    "      Else\n"
    "        Run AmiTCP:bin/inetd {DEBUG}\n"
    "      EndIf\n"
    "    EndIf\n"
    "    ;\n"
    "    ; Start utilities in AmiTCP:db/seiŹnet\n"
    "    ;\n"
    "    If Exists AmiTCP:db/User-Startnet\n"
    "      Execute AmiTCP:db/User-Startnet\n"
    "    EndIf\n"
    "    ;\n"
    "    ; Successfull end\n"
    "    ;\n"
    "    Echoic4.3 is now on-line. Your host name is $HOSTNAME.\n"
    "  Else\n"
    "    Echo Interface {IFACE} SIT failed!\n"
    "    Echo Stopping AmiTCP\n"
    "    AmiTCP:bin/stopnet FLUSH\n"
    "  EndIf\n"
    "Else\n"
    "  Echo AmiTCP couldn't be started!\n"
    "EndIf\n"
    "\n"
    "; EOF\n"
    )))
 (protect (tackon bin-dir "startnet") "+s +e"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 si 
 ;;
 (set add-to-startup-conf
 sLi
       "; These must be placedsFiAmiTCP/IP section\n"
       (if (askbool
	    (prompt "\nDo you want the password of the default user to be "
		    "asked whenskIsis started after a reboot?")
	    (help "    On system startup, the \"root\" is the default user. "
		  "This makes it possible to login with a user name without "
		  "password validation. If you need the password to be asked, "
		  "the user will be changed to \"nobody\" on the system "
		  "startup. This causes the password to be asked when a user "
		  "logs in.\n"s"i|; change the default user to \"nobody\"\n"
		"login -f nobody\n"))
       (if (askbool
	    (prompt
	     "\nDo you want thes
Il
	     " to be started at the system startup?")
	    (help
	     "    If you decide not to start the " @app-name " at "
	     "startup, you can later start it by giving command "
	     "\"startnet\" "
	     "at the command shell."))
	   ((set started-at-boot 1)
	    (tackon bin-dir "startnet\n"))
	 ((set started-at-boot 0)
	  "")))
      complete-add-to-startup-conf
      (cat ";BEGIN " @app-name " Configuration\n"
	   add-to-startup-conf
	   ";END " @app-name " Configuration\n"))
 ;; Ask for confirmation to add
 (if
     (askbool
      (prompt "\nDo you want Installer to make the required changes to "
	      "your s:User-Startup script?\n"
	      "\n(There is a problem with Installer making these "
	      "changes if you do not have the original boot volume "
	      "mounted. Installer may crash or corrupt your system "
	      "in that case.)")
      (help "If you do not want Installer make the changes, it will "
	    "create a script file containing commands which you should "
	    "add to the s:User-Startup file."))
     ;; Do the addition
     ((set startup-changed 1)
      (startup
       (cat @app-name " Configuration")
       (command add-to-startup-conf)
       (prompt "Installer will modify your S:User-Startup file. "
	       "Following lines will be appended to it:\n\n"
	       complete-add-to-startup-conf)
       (help "   Installer needs to make indicated modifications to "
	     "your user startup file to make sure that everything is "
	     "correctly set up to run the " @app-name ".\n"
	     "   You should make the modifications later manually "
	     "if you skip this part.")))
   ;; Let user add commands
   ((set addition-to-user-startup-conf
	 (tackon atcp-assign "addition-to-user-startup-conf"))
    (textfile (dest addition-to-user-startup-conf)
	      (append complete-add-to-startup-conf))
    (message "Installer created file " addition-to-user-startup-conf
	     ", which you can append to your s:User-Startup file manually. "
	     "The file contents is:\n\n"
	     complete-add-to-startup-conf))))
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Linear, first time configuration of AmiTCP/IP
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(procedure
 linear-configuration
 (transcript "First time installation of " @app-name ".")

 ;;
 ;; First time installation ("linear" installation)
 ;;
 (message
  "\n"
  "    Please read the chapter \"Installing and Configuring AmiTCP/IP\" "
  "of the AmiTCP/IP User's Manual before continuing further.\n"
  "    Read the instructions provided behind the \"Help\" "
  "buttons, if you are not absolutely sure what you are doing.\n"
  "    Please read the \"readme\" files from the installation "
  "directory. They contain valuable info you cannot afford to miss."
  )
 ;;
 ;;
 (transcript "Configuring " @app-name ".")
 ;;
 ;; select-provider-config asks user to
 ;; - select provider configuration
 ;; - confirm all the values
 ;;
 (select-provider-config)		; OK ?
 ;;
 ;; Ask for name service configuration, if not dynamic
 ;;
 (if (not pro_NSDynamic)
     ((message "\nNext you will be prompted for name service "
	       "configration.\n")
      (ask-resolv-conf))
   (textfile (dest (tackon conf-dir "resolv.conf"))
	     (append "; You can add search domains here\n")))
 (if pro_NeedSerial
     ((message "\nNext you will be prompted for serial line configuration.\n")
      (configure-serial)))			; OK ?
 (if pro_DialUp
     ((message "\nNext you will be prompted for modem configuration.\n"
	       "You might need your modem manual for reference.\n")
      (configure-modem)))			; OK ?
 (message "\nNext you will be prompted for your login name.\n")
 (ask-default-user)			; OK
 (if (not pro_DialUp)
     (update-user-startup-conf))
 (ask-run-servers)
 (create-startup-script)
 )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Installatation sequence
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;
; Initialize "global" variables to default values (not complete)
;
(set
 cs-use-servers 1
 pro_Interface ""
 pro_Interface ""
 pro_IPAddr ""
 pro_IPDynamic 0
 pro_UseBootP 0
 cs-style-name "none"              ;; should be overridden
 )

(complete 00) (transcript "On configuring " app-name ".")
(complete 01) (check-user-level)
(complete 04) (check-atcp-assign)
(complete 05)

(set @default-dest current-atcp-directory)

;;
;; Either read configuration files or reset to defaults
;;
(set pro_FileName "AmiTCP:db/Provider.conf")
(parse-provider-config)
(parse-if-config)

;
; Check if all the files generated by this script are on place or not
;
(set initial-configuration
     (OR (OR (NOT (exists (tackon conf-dir "resolv.conf")))
	     (NOT (exists pro_FileName)))
	 (OR (OR (NOT (exists "ENV:LOGNAME"))
		 (AND pro_DialUp
		      (= pro_Phone "")))
	     (OR (OR (= pro_Interface "")
		     (= pro_IPAddr ""))
		 (AND (= pro_IPAddr "0.0.0.0")
		      (not pro_IPDynamic))))))

(if initial-configuration
    (linear-configuration)
  (	;; Configuration files existed already
   ((transcript @app-name " already configured, presenting options")
    (while
	((complete 50)
	 (set choice
	      (askchoice
	       (prompt "The " app-name " seems to be already configured. "
		       "Select one of following:")
	       (help "    The AmiTCP/IP configuration files were found on your "
		     "disk.  Usually this means that AmiTCP/IP is already "
		     "configured.\n"
		     "    Now you can change your configuration. "
		     "This selection will "
		     "be repeatedly presented until \"Done\" is selected.\n"
		     "    The choices are:\n"
		     "\"Add new users\" -- allows you to add new users to "
		     "the user database (AmiTCP:db/passwd).\n"
		     "\"Modify Name Service configuration\" -- allows you to "
		     "reconfigure the name servers and search domains.  See "
		     "documentation for the file AmiTCP:db/resolv.conf for "
		     "more information.\n"
		     "\"Modify modem configuration\" -- change the modem "
		     "specific setup information. This selection is effective "
		     "only with DialUp (Non-fixed) configurations.\n"
		     "\"Modify serial configuration\" -- change the serial line "
		     "specific setup. This selection is effective only with "
		     "interfaces utilizing a serial device\n"
		     "\"Modify IP provider configuration\" -- change the setup "
		     "profile for your IP provider. You can reconfigure your "
		     "IP setup with this.\n"
		     "\"Select a new provider configuration\" -- select a new "
		     "IP provider profile.\n"
		     "\"Save provider configuration\" -- save the current "
		     "setup as a IP provider profile.\n"
		     "\"Done\" -- exit the configuration tool.\n"
		     )
	       (choices
		"Add new user to the user data base"	; 0
		"Change default user"			; 1
		"Modify Name Service configuration"	; 2
		"Modify modem configuration"		; 3
		"Modify serial configuration"		; 4
		"Modify IP provider configuration"	; 5
		"Select a new provider configuration"	; 6
		"Save provider configuration"		; 7
		"Update system startup options"		; 8
		"Done")					; 9
	       (default 9)))
	 (<> choice 9))
      (select choice
	      ;; (0)
	      (add-new-user)
	      ;; (1)
	      (ask-default-user)
	      ;; (2)
	      (ask-resolv-conf)
	      ;; (3)
	      (configure-modem)
	      ;; (4)
	      (configure-serial)
	      ;; (5)
	      (configure-provider)
	      ;; (6)
	      (select-provider-config)
	      ;; (7)
	      (save-as-provider-config)
	      ;; (8)
	      ((ask-run-servers)
	       (create-startup-script)
	       (update-user-startup-conf))
	      )
      )
    )
   )
  )

;;; All done!
(complete 100)

(if initial-configuration
    (message "\nConfiguration complete!\n\n"
	     "Use \"Start AmiTCP\" from WorkBench to start " @app-name ".\n")
  (message "\nReconfiguration complete!\n\n"
	   "You need to (re)start " @app-name
	   " for all changes to take effect.\n")
  