(set DestPath                                                  ; Ask for drive on which to install software
    (askdir
        (prompt 'Where do you want to install SoundProbe? A drawer called SoundProbe will be created there.')
        (help 'Select the drive on which you wish to have SoundProbe installed')
        (default (expandpath 'SYS:'))
        (disk)
    )
)
(working '\nUnpacking archive, please wait')
(run 'CUCD25:C/LhA -m -I x SoundProbeCU.lha' DestPath)
(set @default-dest DestPath)
(exit)


; $VER: Wirenet Installer 2.0ß4 (7.5.98) Neil Bothwick
;
; Parts of this installer are based on the installation routines for the
; individual software items, the rest is (c) Neil Bothwick, Wirenet Amiga
; Internet 1996-8 and may not be used in any other package without permission

;;; History
;1.0 (15.04.96)
;    Original release version
;
;1.1 (23.04.96)
;    Altered use of procedures to take advantage of new Installer v43.3 from AT
;
;1.1a (14.05.96)
;    Minor change to specification of signature file for Thor
;
;1.2 (22.05.96)
;    Added conference flag to make Thor post Enter events correctly
;1.2a (28.05.96)
;    Added function to back up old environment varialbes before overwriting
;    Added scrolly welcome message
;1.3  (11.06.96)
;    Added Fetch command to replace GetMail and GetNews
;1.3a (25.07.96)
;    Altered setting of $MAILBOX to suit Hostname Based Mail
;1.4 (23.10.96)
;    Added options for dynamic accounts too
;1.5 (30.10.96)
;    Integrated dynamic and static scripts
;    Added the new v1.5 Dashboard and scripts
;1.6 (10.1.97)
;    Updated to Install AWeb 2.1 Demo, Thor 2.4, AmiFTP 1.814 and the
;    December 18 Classes
;1.7 (24.7.97)
;    Updated to Install AWeb 3.0 Demo, Thor 2.4, AmiFTP 1.814 and the
;    18-May-97 Classes
;2.0 (27.4.98)
;    Added Dashboard2 using GUI4CLI instead of Varexx, plus Thor 2.5a,
;    AmiFTP 1.843, AWeb 3.0b and ClassAct 20-Nov-97
;    Also altered structure of Wirenet directory, to keep SmiTCP and
;    Miami separate

;;;

;========================== Define Procedures ==========================

;;; Set Parameters
(procedure SetParameters
    (set
        FromFloppy
            (if (= (substr (expandpath @icon) 0 9) 'Wirenet1:')
                ('YES')
                ('NO')
            )
        InstVersion         '2.0'
        MinVersion          37                                  ; WB 2.04
        MinMemory           (* 1200 1024)                       ; 2 meg machine
        FreeStorage         5                                   ; Number of MB of free disk space needed
        AmiTCPArc           'Wirenet1:AmiTCP40demo.lzx'         ; Name of AmiTCP archive
        UnarcTcpDir         'AmiTCP-4.0-demo'                   ; Directory AmiTCP unpacks to
        MainDir             'Wirenet'                           ; Main directory to install software
        AmiTCPDir           'Wirenet:AmiTCP'                    ; Directory to install AmiTCP in
        ThorMainArc         'Wirenet2:thor25a_main.lzx'         ; Name of Thor main archive
        ThorInetArc         'Wirenet2:thor25a_inet.lzx'         ; Name of Thor inet archive
        ThorArexxArc        'Wirenet3:thor25a_arexx.lzx'        ; Name of Thor arexx archive
        ThorWelcome         'Wirenet3:ThorWelcome.msg'          ; Message to put into Thor email
        ThorVersion         '2.5'                               ; Version of Thor
        ThorArcDir          (cat 'THOR_' ThorVersion)           ; Name of main directory of Thor archive
        ThorInnerArc        'thor.lzx'                          ; Name of archive within main Thor archive
        ThorPath            'Wirenet:Thor'
        BBSDataPath         (tackon ThorPath 'ThorData')
        ThorSystem          'Wirenet'                           ; Name of Internet system to be created for Thor
        NewsGroups          'InstTemp:db/NewsGroups'            ; File of NewsGroups to subscribe to
        ClassActArc         'Wirenet3:ClassAct.lzx'             ; Contains classes for ClassAct
        AWebArc             'Wirenet3:AWeb.lzx'
        AmiFtpArc           'Wirenet3:AmiFTP.lzx'
        MoreFilesArc1       'Wirenet1:MoreFiles1.lzx'           ; Contains various other files
        MoreFilesArc2       'Wirenet2:MoreFiles2.lzx'           ; Contains various other files
        DocArc              'Wirenet1:Docs.lzx'                 ; Various documentation
        empty               ''
        tick                "'"
    )
    ;Set ISP specific info
    (set Dynamic 'YES')
    (set
        ISP             'Wirenet'               ; name of ISP
        SupportTel      '01925 496482'          ; Telephone support number
        SupportMail     'support@wirenet.co.uk'
        Domain          'u-net.com'             ; Domain names
        DomainNames     1                       ; number of Domain name entries
        GatewayIP                               ; gateway address
                (if (= Dynamic 'YES')
                    ('194.119.131.1')
                    ('193.119.176.1')
                )
        TelNo                                   ; dial in telephone number
                (if (= Dynamic 'YES')
                    ('08453008112')
                    ('08453008111')
                )
        AltTelNo                                ; alternate dial in telephone number
                (if (= Dynamic 'YES')
                    ('08450798112')
                    ('08450798111')
                )
        DialRetries     5                       ; number of times to retry dialling
        ConnectString   'MTU'                   ; string received when connection completed
        NewsServer      'news.u-net.com'        ; Main news server
        MailServer      'mail.u-net.com'        ; Mail host
        MailPoster      'send.mail.u-net.com'   ; Mail posting host
        NewsRetries     6                       ; Number of times to try for connection when posting or getting news
        NameServers     3                       ; number of nameserver entries
        NameServer1     '194.119.131.65'
        NameServer2     '194.119.131.66'
        NameServer3     '130.88.200.4'
        MTU             1500                    ; Max Transfer Unit
        HBM             'YES'                   ; Set to YES for Hostname Based Mail
    )
    ; Set defaults
    (set
        DevName             'serial.device'
        DevUnit             '0'
        #ModemSpeed         1
        IPaddress
            (if (= Dynamic 'YES')
                ('0.0.0.0')
                ('')
            )
        Password    ''
        ModemInit   'AT&F&C1&D2'
        ModemDial   'ATDT'
        ModemOK     'OK'
    )
    (if (not (= FromFloppy 'YES'))
        (
            (makeassign 'Wirenet1' '')
            (makeassign 'Wirenet2' '')
            (makeassign 'Wirenet3' '')
        )
    )
    ; Put UNLZX RAM: to reduce disk swaps
    (run 'Copy UNLZX to RAM: QUIET')
)
;;;
;;; Setup message, prompt and help strings
(procedure SetStrings
    (set
        WelcomeMsg1
            (cat
                '\nWelcome to the ' ISP ' Internet software installation.\n'
                '\nPlease read the readme file on Disk One before starting the installation. This contains '
                'information you will NEED to proceed.\n'
                '\nThen follow the on screen prompts to install and setup the software for your system\n'
                '\nThere is help available at all stages, just click on the help button or press the HELP key.\n'
            )
        WelcomeMsg2
            (cat
                '\nBoth the installation and much of the software needs ARexx to run. If you do not '
                'already run Rexxmast at startup, please do the following before proceeding:\n\n'
                'Open the System drawer on your boot drive and double click on the Rexxmast icon\n\n'
                'Then drag the Rexxmast icon into your WBStartup drawer\n'
            )
        WelcomeMsg3
            (cat
                '\nIf you get completely stuck while installing the software, ring the support line on\n\n'
                SupportTel
                '\n\nAll other technical support is handled by email to\n\n'
                SupportMail
            )
        WelcomeMsg4
            (cat
                '\nThis installer is (c) 1996-8 Neil Bothwick\n<' SupportMail '>\n\n'
                'The copyright of all other software on these disks remains with the respective authors.\n'
                '\nSome of the software is shareware, registration details are given in the relevant documentation.\n'
            )
;        WelcomeMsg
;            (cat WelcomeMsg1 WelcomeMsg2 WelcomeMsg3 WelcomeMsg4)
        NoArexxMsg
            (cat
                '\nThe installation cannot proceed without Rexxmast running.\n\nPlease follow the '
                'instructions in the installation section of the documentation before trying '
                'to install.'
            )
        UserInfoPrompt
            (cat
                'First I will ask you a few questions.\nYou will need the following information:\n\n'
                'Your real name\nYour user name\nYour node name\n'
                (if (not (= Dynamic 'YES'))
                    ('Your IP address\n')
                )
                'Your password\nYour organisation\n\nPlease take the time to read the help for each '
                'item if you are in any way unsure of anything.'
            )
        ModemInfoPrompt
            (cat
                '\nNow I will ask you some questions about your modem.\n\n'
                'If you are unsure of any of this information and you are using a standard modem, '
                'then the defaults should work OK.\n'
            )
        OS13Msg
            '\nYou need at least version 2.04 of the Amiga Operating System to run the software in this package.'
        MoreMemMsg
            'You need at least 2MB of RAM in your Amiga to run the software in this package.'
        UnpackMsg
            'Extracting files from archive.\n\nI may be some time...'
        ConfigAmitcpMsg
            '\nSetting up AmiTCP to suit your system'
        DevNameError
            ''
        CopyIFMsg
            (cat '\nInstalling the ' InterfaceDev ' device driver to dial and make a connection to ' ISP)
        RealNameHelp
            '\nReal Name:\n\nYou know, your real name!\n\nThis is added to messages you post.\n'
        UserNameHelp
            (cat
                '\nUser Name:\n\nThis is the name you will be referred to as the user of this machine. '
                'It was included in the letter you received when joining ' ISP ' and is the part of your '
                'email address to the left of the @\n'
            )
        NodeNameHelp
            (cat
                '\nNode Name:\n\nThis will have been agreed between you and ' ISP ' when you opened your '
                'account. It is the part of your email address between the @ and the first dot\n')
        IPaddressHelp
            (cat
                '\nIP Address:\n\nThis is your numeric internet address, consisting of four numbers separated by '
                'full stops, like:\n\n      123.456.78.90\n\nYou should have been told this by ' ISP ' when you '
                'opened your account.\n'
            )
        PasswordHelp
            (cat
                '\nPassword:\n\nChoose a password that is easy for you to remember and difficult for others to guess.'
                '\n\nDo not use a password from another system, and do not disclose this password to anyone.\n'
            )
        OrganisationHelp
            '\nOrganisation:\n\nThis will be listed in the headers of messages you send\n'
        UserInfoHelp
            (cat
                RealNameHelp
                UserNameHelp
                NodeNameHelp
                (if (not (= Dynamic 'YES'))
                    (IPaddressHelp)
                )
                PasswordHelp
                OrganisationHelp
                '\nIf you do not have all of this information now, you will have to abort the installation until you '
                'have it all ready'
            )
        VerifyUserHelp
            (cat
                '\nYou MUST check these details extremely carefully, if they are not EXACTLY right '
                'you may not be able to connect to the internet.'
            )
        DevNamePrompt
            (cat
                'Please select the serial device you use.\nThe default is fine up to 38400 baud, but '
                'sometimes causes problems at 57600.\n\nartser.device is the recommended replacement.\n\n'
                'See help if using anything but serial.device'
            )
        DevNameHelp
            (cat
                '\nThe device you choose must be in your DEVS: drawer, unless your are using a MultiFace '
                'serial card and want to use duart.device.\n\n'
                'Do not use either baudbandit.device or 8n1.device, these can be unreliable for Internet use.\n\n'
                'If in doubt select the default.'
            )
        ModemSpeedPrompt
            (cat
                'Please select the speed of the serial link between between your Amiga and your modem. '
                'The default is usually best, 57600 is better IF your system can handle it. See Help '
                'for more information.'
            )
        ModemSpeedHelp
            (cat
                '\nModem Speed:\n\nThis is the speed of the connection between your Amiga and your modem. '
                'This needs to be higher than the speed of connection between modems, in order to use '
                'data compression. If you set it too high you may experience data loss.\n'
                'Use 38400 for a 14.4K modem with a 68020 or 68030 processor.\n'
                'Use 56700 for a 28.8K modem PROVIDED you have at least a 68030 processor.\n'
                'Use 19200 if you have a 68000 processor.\n'
            )
        ModemInitHelp
            (cat
                '\nModem Init String:\n\nThis is the command sent to your modem before trying to make a '
                'connection. Check your modem manual if you plan to use anything other than the default.\n'
            )
        ModemDialHelp
            (cat
                '\nModem Dial String:\n\nThis is the command sent to your modem before the phone number. '
                'If you only have pulse dialling on your phone line (very rare now) then use ATDP. DO NOT '
                'include the actual phone number in here.\n'
            )
        ModemOKHelp
            '\nModem OK string:\n\nThis is the string your modem returns to indicate a successful operation.\n'
        TelNoHelp
            (cat
                '\nTelephone Number:\n\nYou generally have a choice of two telephone numbers.\n\n'
                '     ' TelNo ' local call via Cable & Wireless\n'
                '     ' AltTelNo ' local call via EnergisCabvle & Wireless\n'
                '\nDepending on your local telephone network, you may find one better than the other.\n'
            )
        ModemInfoHelp
            (cat
                ModemSpeedHelp
                ModemInitHelp
                ModemDialHelp
                ModemOKHelp
                TelNoHelp
                '\nIf you do not have all of this information now, you will almost certainly be able to connect '
                'using the defaults given.'
            )
        VerifyModemHelp
                '\nPlease check these details carefully before proceeding.'
        MainDirPrompt
            (cat
                'Please select the drive on which you wish to install the internet software.\n'
                'It should have at least ' FreeStorage 'MB of free space.\n'
                'A drawer called ' MainDir ' will created on this drive.'
            )
        MainDirHelp
            (cat
                '\nYou need to specify the hard disk or partition on which you want to install the '
                'software.\n\nDO NOT specify a drawer on the drive, one will be created which should '
                'not be inside another drawer.'
            )
        CopyIFHelp
            (cat
                '\nI will now copy ' InterfaceDev ' to your DEVS:Networks drawer.\n\n'
                'This takes care of connecting your modem to ' ISP '.'
            )
        ThorInstPrompt
            (cat
                '\nYou appear to already have Thor installed, '
                'do you want to install it again from scratch?'
            )
        ThorInstHelp
            (cat
                '\nThere appears to be a previous installation of Thor.\n\n'
                'Select YES if you want to make a complete new installation from scratch.\n\n'
                'Otherwise select NO and read the following information on how to use Thor '
                'with the supplied software.'
            )
        ExistingThorMsg1
            (cat
                '\nYou can use your current Thor setup with Wirenet if you make these changes '
                'in ConnectThor config:\n\nSet the MailServer to mail.u-net.com\nSet the NewsServer '
                'to news.u-net.com\nSet your login address to '
            )
        ExistingThorMsg2
            (cat
                '@mail.u-net.com\n\nSome of the supplied scripts assume a system name of Wirenet, '
                'so you may need to change these if you use them.'
            )
        IconSetHelp
            (cat
                '\nIf you use MagicWB on your Workbench, '
                'you might want to install the special MagicWB icons.\n\n'
                'Likewise, if you use NewIcons on your Workbench, '
                'you might want to install the special NewIcons icons.\n\n'
                'Note: The NewIcons will only show up if you are running the NewIcons software.'
            )
        ThorImportHelp
            (cat
                '\nThis will convert your existing Mail and News files to the Thor database.\n\n'
                'Your old mail and news directories will *not* be deleted.\n\n'
                'This only applies if you are changing from another Internet provider and have '
                'some existing news and mail files in non-Thor format.'
            )
        NeedOS3forAWeb
            (cat
                'AWeb, the supplied World Wide Web Browser, requires OS 3.0 or later to function.\n\n'
                'The only graphical Web browser that works with OS 2.04 is AMosaic 1.2. '
                'This is available by ftp from ftp.demon.co.uk in the amiga/comm/tcp directory.'
            )
        AWebMemPrompt
            'Is your Amiga equipped with more than 2MB of memory?'
        AWebMemHelp
            (cat
                'AWeb runs perfectly on a 2MB Amiga, but needs a special setup on such a machine. '
                'If you click the "only 2MB" button, the appropriate settings will be installed.\n\n'
                'You can always change the settings after installation.'
            )

        AWebFFPrompt
            'The FixFonts utility will be run to make the newly added fonts available.'
        AWebFFHelp
            (cat
                'The FixFonts utility is needed to make the newly added fonts available to the system.\n\n'
                'You are strongly encouraged to run FixFonts now.\n\n'
                'Note that running this program may take a while.'
            )
        AWebHelpMsg
            (cat
                '\nIn case you need help configuring or using AWeb-II DEMO, pressing the HELP key when '
                'AWeb is active will bring up the documentation.\nI hope you will enjoy using this demo '
                'and will consider purchasing the full version'
            )
        StartAmiTcpMsg
            '\n\nNow installing AmiTCP.\n\nThis provides the basic connection to the Internet.'
        StartThorMsg
            '\n\nNow installing Thor.\n\nThis is the mail and news program.'
        StartAmiFtpMsg
            '\n\nNow installing AmiFTP.\n\nThis will allow you to download software and other files from remote computers.'
        StartAWebMsg
            (cat
                '\nNow installing AWeb-II, a fast, multithreaded World Wide Web browser for Amiga OS 3.0.\n\n'
                'It understands virtually all widely used HTML and has many other features, including an '
                'ARexx and Shell command interface.'
            )
        DatatypeMsg
            (cat
                '\nNow installing datatypes for JPEG and GIF images.\n\n'
                'These are the two most commonly used image formats on the World Wide Web. '
                'Others you may wish to install are for png images and for au and wav sounds. '
                'These are all available from Aminet in the util/dtype directory.\n\n'
                'The datatypes will not be installed if you already have GIF and/or JPEG datatypes on your system.'
            )
        FinalMsg
            (cat
                '\n\All done\n\nYou are now ready to connect to the Internet. Please read the documenation for each '
                'program as it gives vital information for getting the most out of your Internet access.\n\n'
                'Particularly, read Wirenet.guide before going online for the first time.'
            )
        ResetMsg
            (cat
                '\n\nIt is recommended that you reset your Amiga before running the software '
                'for the first time.\n\nThis will ensure that the commands added to your user-startup '
                'are executed before you go online.'
            )
    )
)
;;;
;;; Abort with message
(procedure GetOut GetOutMsg
    (message GetOutMsg)
    (exit (quiet))
)
;;;
;;; Create environment variable
(procedure SetEnv EnvName EnvVal                                ; Creates environment variables in ENV: and ENVARC:
    (set ArcName (tackon 'ENVARC:' EnvName))
    (if (exists ArcName)                                        ; Back it up if it already exists,
        (if (not (exists (cat ArcName '.old')))                 ; has not been previously backed up
            (if (not(= EnvVal (getenv EnvName)))                ; and is not the same value
                (rename ArcName (cat ArcName '.old'))
            )
        )
    )
    (textfile
        (dest (tackon 'ENVARC:' EnvName))
        (append EnvVal)
    )
    (textfile
        (dest (tackon 'ENV:' EnvName))
        (append EnvVal)
    )
)
;;;
;;; Ensure disk is inserted
(procedure GetDisk NextFile
    (set DiskName (pathonly NextFile))
    (set DiskName (substr DiskName 0 (- (strlen DiskName) 1)))
    (askdisk
        (prompt (cat '\nPlease insert disk ' DiskName ': into any drive'))
        (help '\nA file on this disk is needed to continue with the installation')
        (dest DiskName)
        (assigns)
    )
)
;;;
;;; Unarchive file
(procedure UnArc ArcFile ArcDest ArcMsg
    (working (cat '\n' ArcMsg))
    (GetDisk ArcFile)
    (if (< 0 (run 'RAM:unlzx -m x' ArcFile ArcDest))            ; Unpack archive
        (GetOut (cat '\nFailed to unarchive ' ArcFile '\n\nPlease check the file'))
    )

    ;(set ArcFiles (substr ArcFile 0 (- (strlen ArcFile) 4)))
    ;(copyfiles
    ;    (prompt '')
    ;    (help '')
    ;    (source ArcFiles)
    ;    (dest ArcDest)
    ;    (all)
    ;    (nogauge)
    ;)
)
;;;
;;; Say hello :-}
(procedure WaitX (set X 1) ( (while (< X 80)  (set X (+ X 1)) )  ) )
(procedure LineFeed lines
    (substr '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' 0 lines)
)

(procedure SayHello
    (set
        Line1   '\nWelcome to the'
        Line2   'Wirenet Amiga Internet'
        Line3   'software installation'
    )
    (set LFs 12 LFmin 1)
    (while (> LFs LFmin)
        (working (cat (LineFeed LFs) Line1)) (WaitX)
        (set LFs (- Lfs 1))
    )
    (WaitX)
    (set LFs 12 LFmin 3)
    (while (> LFs LFmin)
        (working (cat Line1 (LineFeed LFs) Line2)) (WaitX)
        (set LFs (- Lfs 1))
    )
    (WaitX)
    (set LFs 9 LFmin 2)
    (while (> LFs LFmin)
        (working (cat Line1 (LineFeed 3) Line2 (LineFeed LFs) Line3)) (WaitX)
        (set LFs (- Lfs 1))
    )
    (message (cat '\n\n' Line1 (LineFeed 3) Line2 (LineFeed 3) Line3))
    (message WelcomeMsg1)
    (message WelcomeMsg2)
    (message WelcomeMsg3)
    (message WelcomeMsg4)
    (welcome)
)
;;;
;;; Check system
(procedure CheckSystem
    (set OS (/ (getversion) 65536))
    (set CPU (database "cpu"))
    (set ChipMem (database "graphics-mem"))
    (set FreeMem (database "total-mem"))
    (set cpu020 (and (<> cpu "68000") (<> cpu "68010")))
    (set v39 (>= (/ (getversion "exec.library" (resident)) 65536) 39))

    (if (< OS MinVersion)                                       ; Abort if KS < 2.04
        (GetOut OS13Msg)
    )
    ;(if (< FreeMem MinMemory)                                  ; Abort if < 2MB RAM
    ;    (GetOut MoreMemMsg)
    ;)
    (set WB (select (- os 33) '1.2' '1.3' ' ' '2.0' '2.04' '2.1' '3.0' '3.1' ))
    (if (run 'rx "address command"')
        (if (run 'sys:rexxc/rx "address command"')
            (GetOut NoArexxMsg)
        )
    )
)
;;;
;;; Check for existing AmiTCP installation
(procedure CheckForAmiTCP
    (if (exists ('AmiTCP:AmiTCP' (noreq)))
        (
            (set vernum (getversion 'AmiTCP:AmiTCP'))
            (set ver (/ vernum 65536))
            (set rev (- vernum (* ver 65536)))
            (if (< ver 4)
                (
                    (message
                        (cat
                            '\nYou already have AmiTCP 'ver'.'rev ' installed.\n\nI will install AmiTCP 4.0 in a '
                            'new directory. Your old AmiTCP installation will remain untouched.'
                        )
                    )
                )
                (
                    (message
                        (cat
                            '\nYou already have AmiTCP v'ver'.'rev ' installed.\n\nI will install AmiTCP 4.0 in a '
                            'new directory. Your old AmiTCP installation will remain intouched.'
                        )
                    )
                )
            )
        )
    )
)
;;;
;;; Read environment variables
(procedure ReadEnv
    (working "Reading Environment Variables...")
    (set
        RealName
            (if (exists 'ENV:REALNAME' (noreq))
                (getenv 'REALNAME')
                ''
            )
        UserName
            (if (exists 'ENV:USERNAME' (noreq))
                (getenv 'USERNAME')
                (if (exists 'ENV:USER' (noreq))
                    (getenv 'USER')
                    ''
                )
            )
        NodeName
            (if (exists 'ENV:NODENAME' (noreq))
                (getenv 'NODENAME')
                ''
            )
        Organisation
            (if (exists 'ENV:ORGANIZATION' (noreq))
                (getenv 'ORGANIZATION')
                (if (exists 'ENV:ORGANISATION' (noreq))
                    (getenv 'ORGANISATION')
                    'At Home'
                )
            )
    )

)
;;;
;;; Get user information
(procedure GetUserInfo
    (message
            (UserInfoPrompt)
            (help UserInfoHelp)
    )
    (set
        RealName
            (askstring
                (prompt '\nPlease enter your real name')
                (help RealNameHelp)
                (default RealName)
            )
        UserName
            (askstring
                (prompt '\nPlease enter your user name')
                (help UserNameHelp)
                (default UserName)
            )
        NodeName
            (askstring
                (prompt '\nPlease enter your hostname')
                (help NodeNameHelp)
                (default NodeName)
            )
        HostName (cat NodeName '.' Domain)
        MailAddress (cat UserName '@' HostName)
        MailUser
            (if (= HBM 'YES')
                (NodeName)
                (cat UserName '-' NodeName)
            )
        IPaddress
            (if (not (= Dynamic 'YES'))
                (askstring
                    (prompt '\nPlease enter your IP address')
                    (help IPaddressHelp )
                    (default IPaddress)
                )
                ('0.0.0.0')
            )
        Password
            (askstring
                (prompt '\nPlease enter your password')
                (help PasswordHelp)
                (default Password)
            )
        Organisation
            (askstring
                (prompt '\nPlease enter your organisation')
                (help OrganisationHelp )
                (default Organisation)
            )
    )
    ; Verify user information
    (askbool
        (prompt
            (cat
                '\nYou gave the following information\n'
                '\nReal name: ' RealName
                '\nUser name: ' UserName
                '\nHost name: ' NodeName
                (if (not (= Dynamic 'YES'))
                    (cat '\nIP address: ' IPaddress)
                )
                '\nPassword: ' Password
                '\nOrganisation: ' Organisation
                '\n\nPlease check these details VERY carefully before proceeding'
            )
        )
        (help VerifyUserHelp)
        (choices 'Let me change them' 'They are correct')
    )
)
;;;
;;; Get modem information
(procedure GetModemInfo
    (message
            (ModemInfoPrompt)
            (help ModemInfoHelp)
    )
    (set
        DevName
            (askstring
                (prompt DevNamePrompt)
                (default DevName)
                (help DevNameHelp)
            )
        DevUnit
            (askstring
                (prompt '\nPlease select the unit number of ' DevName)
                (default DevUnit)
                (help '\nThis is usually 0')
            )
        #ModemSpeed
            (askchoice
                (prompt ModemSpeedPrompt)
                (help ModemSpeedHelp)
                (choices
                    '\x1B[2p57600'
                    '38400'
                    '19200'
                    '9600'
                    '4800'
                    '2400'
                )
                (default #ModemSpeed)
            )
        ModemSpeed
            (select #ModemSpeed '57600' '38400' '19200' '9600' '4800' '2400')
        ModemInit
            (askstring
                (prompt '\nPlease enter the initialisation string for your modem')
                (help ModemInitHelp)
                (default ModemInit)
            )
        ModemDial
            (askstring
                (prompt '\nPlease enter the dial string for your modem')
                (help ModemDialHelp)
                (default ModemDial)
            )
        ModemOK
            (askstring
                (prompt '\nPlease enter the OK response for your modem')
                (help ModemOKHelp)
                (default ModemOK)
            )
        TelNo
            (askstring
                (prompt '\nPlease enter your nearest access telephone number')
                (help TelNoHelp )
                (default TelNo)
            )
    )
    ; Verify modem information
    (askbool
        (prompt
            (cat
                'You have given the following details about your modem connection\n\nDevice name: ' DevName
                '\nUnit number: ' DevUnit '\nSerial link speed: ' ModemSpeed'\nInitialisation string: ' ModemInit
                '\nDial String: ' ModemDial '\nOK string: ' ModemOK '\nTelephone number: ' TelNo
                '\n\nPlease check these details carefully.'
            )
        )
        (help VerifyModemHelp)
        (choices 'Let me change them' 'They are correct')
    )
)
;;;
;;; Create installation directory and ask for icon set
(procedure MakeMainDir
    (set IconSet
        (askchoice
            (prompt '\nSome of the software come with a choice of alternative icons.\n\nPlease select the icon set you want to install.\n')
            (help IconSetHelp)
            (choices
                '\x1B[2pNormal Icons'
                'MagicWB Icons'
                'NewIcons'
            )
            (default 0)
        )
    )

    (message StartAmiTcpMsg)
    (until (= IsDrive 'True')
        (set Drive                                                  ; Ask for drive on which to install software
            (askdir
                (prompt MainDirPrompt)
                (help MainDirHelp)
                (default (expandpath 'SYS:'))
                (disk)
            )
        )
        (set IsDrive                                                ; Check it is a drive, not a drawer
            (if (= (substr drive (- (strlen (expandpath Drive)) 1) 1) ':')
                ('True')
                ('False')
            )
        )
    )
    (set InstallPath (tackon Drive MainDir))
    (if (exists InstallPath)
        (
            (message '\n\nYou already have a drawer called ' MainDir ' on ' drive '\n\nRenaming it to ' InstallPath '.old')
            (rename InstallPath (cat InstallPath '.old'))
        )
    )
    (makedir InstallPath (infos))
    (makeassign 'Wirenet' InstallPath)
    (set MainDir 'Wirenet:')
)
;;;
;;; Unarchive and install AmiTCP
(procedure InstallAmiTCP
    (makedir (tackon MainDir UnarcTcpDir) (infos))
    (UnArc AmiTCPArc MainDir UnpackMsg)                                 ; Unpack AmiTCP archive to AmiTCP directory
    (rename (tackon MainDir UnarcTcpDir) (tackon MainDir AmiTCPDir))    ; Rename installation directory to Internet
    (rename (cat (tackon MainDir UnarcTcpDir) '.info') (cat AmiTCPDir '.info'))
    (makeassign 'AmiTCP' AmiTCPDir)

    (working '\nInstalling fonts')
    (copyfiles                                                      ; Copy fonts for napsaterm
        (prompt ' ')
        (help '')
        (source 'AmiTCP:export/Fonts')
        (dest 'FONTS:')
        (all)
        (fonts)
        (nogauge)
    )
    (working '\nRemoving unnecessary files')
    (delete 'AmiTCP:HowToInstall')
    (delete 'AmiTCP:HowToInstall.info')
    (delete 'AmiTCP:Install_AmiTCP')
    (delete 'AmiTCP:Install_AmiTCP.info')
    (delete 'AmiTCP:bin/stopnet')
)
;;;
;;; Unpack extra files
(procedure UnarcExtras
    (copyfiles
        (source 'Wirenet1:Wirenet.guide')
        (dest 'Wirenet:')
        (prompt ' ')
        (help ' ')
        (infos)
    )

    (makedir (tackon MainDir 'InstTempDir'))                        ; Create temporary directory for installer
    (makeassign 'InstTemp' (tackon MainDir 'InstTempDir'))
    (UnArc DocArc 'Wirenet:' 'Unpacking some other files')          ; Unpack documentation
    (UnArc MoreFilesArc1 'InstTemp:' 'Unpacking some other files')  ; and various setup files
    (UnArc MoreFilesArc2 'InstTemp:' 'Unpacking some other files')
)
;;;
;;; Copy libraries
(procedure CopyLibraries
    (copylib
        (prompt '\nCopying socket.library')
        (help '\nsocket.library is used by several internet programs to use AmiTCP.')
        (source 'InstTemp:libs/socket.library')
        (dest 'AmiTCP:libs')
        (confirm)
    )
    (delete 'InstTemp:libs/socket.library')
    (foreach 'InstTemp:libs' '#?'
        (copylib
            (prompt (cat '\nCopying ' @each-name))
            (help
                (cat
                    'This will copy ' @each-name ' to your libs drawer, '
                    'unless you already have a newer version there.'
                )
            )
            (source (tackon 'InstTemp:libs' @each-name))
            (dest 'LIBS:')
            (confirm)
        )
    )
)
;;;
;;; Install PPP Interface
(procedure InstallPPP
    (working '\nInstalling your dialup software')
    (set PPPdev
        (if cpu020
            ('ppp.device.020.eval')
            ('ppp.device.000.eval')
        )
    )
    (copylib
        (prompt CopyIFMsg)
        (help CopyIFHelp)
        (source (tackon 'InstTemp:devs' PPPdev))
        (dest 'DEVS:Networks')
        (newname 'ppp.device')
        (confirm)
    )
)
;;;
;;; Setup files in AmiTCP:db
(procedure SetupDB
    (working ConfigAmitcpMsg)
    ; Add appropriate lines to AmiTCP:config
    (textfile
        (dest 'AmiTCP:db/AmiTCP.config')
        (include 'InstTemp:db/AmiTCP.config')
        (append  (cat 'hostname=' HostName '\n'))
        (append 'consolename="CON:0/15/600/100/AmiTCP Log/AUTO/CLOSE/INACTIVE"\n')
        (append 'logfilename="Logs:AmiTCP.log"\n')
    )
    ; Copy Interfaces to AmiTCP:db
    (copyfiles
        (source 'InstTemp:db/Interfaces')
        (dest 'AmiTCP:db')
    )
    ; Copy inetd.conf with safe fingerd
    (copyfiles
        (source 'InstTemp:db/inetd.conf')
        (dest 'AmiTCP:db')
    )
    ; add hostname to AmiTCP:db/hosts
    (textfile
        (dest 'AmiTCP:db/hosts')
        (append '#\n#       The hosts database file for AmiTCP/IP.\n#\n')
        (append '127.0.0.1 localhost\n')
        (if (not (= Dynamic 'YES'))
            (append IPaddress ' ' HostName '\n')
        )
        (append ';\n;EOF\n')
    )
    ; Create motd in AmiTCP:db
    (textfile
        (dest 'AmiTCP:db/motd')
        (append '\n     ' hostname ' is up and running.\n       You are now ready to connect to Wirenet\n')
        (append "the UK's first Amiga only internet access provider\n\n")
    )
    ; Create resolv.conf in AmiTCP:db (and delete the example)
    ; Set up string containing nameserver entries
    (set ns 0  ns$ '')
    (while (< ns NameServers)
        (
            (set ns$ (cat ns$ 'NAMESERVER ' (select ns NameServer1 NameServer2 NameServer3 NameServer4 NameServer5 NameServer6 nameserver7 nameserver8 nameserver9) '\n'))
            (set ns (+ 1 ns))
        )
    )
    ; Set up string containing Domain name entries
    (set dm 0  dm$ '')
    (while (< dm DomainNames)
        (
            (set dm$ (cat dm$ 'Domain ' (select dm Domain Domain1 Domain2 Domain3 Domain4 Domain5 Domain6 Domain7) '\n'))
            (set dm (+ 1 dm))
        )
    )
    ; Write to db/resolv.conf
    (textfile
        (dest 'AmiTCP:db/resolv.conf')
        (append '; Name servers\n')
        (append ns$)
        (append '\n; Domain names\n')
        (append dm$)
    )
    (delete 'AmiTCP:db/resolv.conf-example')
    ; Create db/passwd
    (textfile
        (dest 'AmiTCP:db/passwd')
        (append (cat 'root||0|0||sys:|shell\n'))
        (append (cat UserName '||100|100|' RealName '|usr:' UserName '|shell\n'))
    )
    (delete 'AmiTCP:db/passwd-example')
    (copyfiles
        (prompt '')
        (help '')
        (source 'InstTemp:db')
        (pattern 'User-#?')
        (dest 'AmiTCP:db')
    )
)
;;;
;;; Copy various scripts
(procedure CopyScripts
    (makedir (tackon MainDir 'bin'))
    (working '\n\nCopying scripts to access the Internet from your system...')
    ; Set script bits
    (foreach 'InstTemp:scripts' '~(ifcheck)'
        (protect (tackon 'InstTemp:scripts' @each-name) '+s')
    )
    (foreach 'InstTemp:UserScripts' '#?'
        (protect (tackon 'InstTemp:UserScripts' @each-name) '+s')
    )
    ; Copy scripts
    (copyfiles
        (prompt '\n\nCopying scripts to access the Internet from your system...')
        (help ' ')
        (source 'InstTemp:scripts')
        (dest (tackon MainDir 'bin'))
        (all)
        (nogauge)
    )
    (copyfiles
        (prompt '\n\nCopying scripts to access the Internet from your system...')
        (help ' ')
        (source 'InstTemp:UserScripts')
        (dest (tackon MainDir 'UserScripts'))
        (all)
        (nogauge)
    )
    ; Copy dashboard
    (copyfiles
        (source 'InstTemp:Dashboard')
        (dest MainDir)
        (files)
        (infos)
        (prompt ' ')
        (help ' ')
        (nogauge)
    )
)
;;;
;;; Setup files in Wirenet:bin
(procedure SetupBin
    (copyfiles
        (source 'InstTemp:bin')
        (dest 'AmiTCP:bin')
        (all)
        (prompt '')
        (help '')
    )
    (CopyScripts)

    (protect 'AmiTCP:bin/ch_nfsctl' '+s')                       ; Set the script bits on the files that
    (protect 'AmiTCP:bin/netstat'   '+s')                       ; should have had them anyway
    (protect 'AmiTCP:bin/SynClock'  '+s')
)
;;;
;;; Create Environment variables and Wirenet.prefs file
(procedure MakeEnvs
    (makedir 'ENV:sana2')
    (makedir 'ENVARC:sana2')
    (SetEnv 'SOCKETCONFIG'  (cat 'UID=100 GID=100 USER=' UserName ' Domain=' Domain ' UMASK=022'))
    (SetEnv 'USER'          UserName)
    (SetEnv 'REALNAME'      RealName)
    (SetEnv 'NODENAME'      NodeName)
    (SetEnv 'IPADDRESS'     IPaddress)
    (SetEnv 'DOMAINNAME'    (cat '.' Domain))
    (SetEnv 'HOST'          (cat NodeName '.' Domain))
)
(procedure MakePrefs
    (textfile
        (dest 'ENVARC:Wirenet.prefs')
        (append '# Wirenet preferences file\n')

        (append '\n# Dialer preferences\n')
        (append (cat 'PopNum: ' TelNo '\n'))
        (append (cat 'ModemDev: ' DevName ' ' DevUnit '\n'))
        (append (cat 'ModemSpeed: ' ModemSpeed '\n'))
        (append (cat 'ModemInit: ' ModemInit '\n'))
        (append (cat 'ModemDial: ' ModemDial '\n'))
        (append (cat 'PPPoptions: CD 7WIRE EOFMODE\n'))
        (append (cat 'MTU: ' MTU '\n'))
        (append (cat 'DialWindow: CON:20/50/400/160/Dialing.../INACTIVE\n'))
        (append (cat 'UsePAP: 0\n'))
        (append (cat 'TCPstack: 0\n'))

        (append '\n# User preferences\n')
        (append (cat 'UserName: ' UserName '\n'))
        (append (cat 'NodeName: ' NodeName '\n'))
        (append (cat 'MailBox: ' MailUser '\n'))
        (append (cat 'DomainName: .' Domain '\n'))
        (append (cat 'IPAddress: ' IPaddress '\n'))
        (append (cat 'Password: ' Password '\n'))

        (append '\n# Address preferences\n')
        (append (cat 'Gateway: ' GatewayIP '\n'))
        (append (cat 'MailServer: ' MailServer '\n'))
        (append (cat 'NewsServer: ' NewsServer '\n'))
        (append (cat 'SMTPServer: ' MailPoster '\n'))
        (append (cat 'NewsSockets: ' 4 '\n'))
        (append (cat 'MaxTries: ' 5 '\n'))

        (append '\n# FTP preferences\n')
        (append (cat 'AminetServer: ' sunsite.doc.ic.ac.uk '\n'))
        (append (cat 'DownloadDir:\n'))
        (append (cat 'AminetRoot:\n'))
        (append (cat 'GetReadme: ' 1 '\n'))
        (append (cat 'WWW: Wirenet:AWeb3/AWeb\n'))
        (append (cat 'FTP: Wirenet:AmiFTP/AmiFTP\n'))
        (append (cat 'ButtonA: User A\n'))
        (append (cat 'ButtonB: User B\n'))
    )
    (copyfiles
        (prompt '')
        (help '')
        (source 'ENVARC:Wirenet.prefs')
        (dest 'ENV:')
        (nogauge)
    )
)

;;;
;;; ClassAct Installer
; ---------------------------------------------------------------------------

; ************* PLEASE COPY THIS PROCEDURE ALONG WITH THE STRINGS IT USES
; ************* TO THE INSTALLER SCRIPT OF YOUR CLASSACT APPLICATION.
; ************* IT WILL TAKE CARE OF INSTALLING THE CLASSACT CLASSES YOU
; ************* PROVIDED WITH YOUR APPLICATION TO THE USER'S SYSTEM.

; $VER: ClassAct_Install 1.16 (9.3.97) by Osma Ahvenlampi

; percentage of the size of included ClassAct classes versus the whole
; distribution (ie. total "complete" percentage after ClassAct is installed)
; (set classact-complete 50)

; Complete reporting removed and changes made to integrate with the Wirenet Installer

; ClassAct installer scripts
(set #classdest-prompt "Please select the directory where you want the ClassAct classes installed.\n(See help for details)")
(set #classdest-help (cat "ClassAct is a GUI toolkit consisting of shared BOOPSI classes.\n\nSome programs require some or all of the ClassAct classes installed on your system. "
    (if v39 (cat "OS 3.0 has a standard directory for BOOPSI classes, the SYS:Classes directory. It is recommended that you install ClassAct there.")
            (cat "OS 2.0 does not have a standard place for disk resident BOOPSI classes. On OS 3.0 these classes are stored in the SYS:Classes directory. It is recommended that you create this directory and install ClassAct there.\n"
                 "This directory must be added in the LIBS: assign. This can be done by placing the command\nAssign >NIL: LIBS: SYS:Classes ADD\nto User-Startup. This installer will do this for you.")
        )
    )
)

(set #classes-020 "Do you want to use the OS 3.0, 020 optimised version of ClassAct?")
(set #help-020 "Some ClassAct libraries have versions optimised for use on 020 or better equipped OS 3.0 or later machines. If your Amiga is such equipped, you should install these. The 68000/2.0 versions will also work, but are slightly slower.")
(set #noclasses-message "The directory you selected for your ClassAct classes is not a part of the LIBS: assign.\n\nIt is necessary to add this assign so that the classes will be found properly.")
(set #creating-dir "Creating directory ")
(set #usbackup-prompt "User-Startup will now be backed up.")
(set #usbackup-help "This installer will next make a modification in User-Startup. Before doing this the old User-Startup will be backed up to S:User-Startup.old")
(set #adding-1 "Adding ")
(set #adding-2 " to LIBS: assign\n")
(set #adding-help "This is necessary so that the custom classes can be found.")
(set #junod-button (cat "It seems you have a late Commodore 'V42' button.gadget installed on your system.\n\nClassAct's button.gadget is far more capable than this gadget, and we recommend that you replace it. "
                        "The ClassAct button.gadget is backwards compatible to the Commodore gadget. Do you wish to back up the Commodore gadget and replace it with the ClassAct version?")
                   )
(set #junod-backed "The Commodore 'V42' button.gadget has been backed up with the name button.gadget.v42.\n\nThe ClassAct button.gadget will be installed in its place.")
(set #junod-kept "The Commodore 'V42' button.gadget was not replaced with the more capable ClassAct version.\n\nPrograms depending on the availability of ClassAct-only features will be likely to work wrong.")
(set #caprefs-message (cat "ClassAct has several user-configurable aspects that affect the look of ClassAct interfaces.\n\nThese settings can be changed using the ClassAct preferences tool that will be installed in yout Prefs drawer.\n\n"
                           "A small tool, CAPrefs, will be added to your user-startup to load the settings on reboot.")
                      )
(set #caprefs-startup-1 "Adding the command\n\n")
(set #caprefs-startup-2 "\n\nTo your s:User-Startup.")
(set #decompressing-classact "Compressed ClassAct distribution detected\n\nDecompressing to RAM:")
(set #deleting-cltmp "Deleting temporary files")

(procedure install-classact ; call this procedure to copy the classes included in the Classes directory
                            ; in your distribution dir.

    (set @classact-source "InstTemp:ClassAct")
    (if (exists (tackon @classact-source "Classes")) ; The archive contains a ClassAct library update.
        (
            ;(set comp-dest  (/ (* classact-complete 2) 10))
            ;(set comp-libs  (/ (* classact-complete 3) 10))
            ;(set comp-dirs  (/ (* classact-complete 4) 10))
            ;(set comp-junod (/ (* classact-complete 5) 10))
            ;(set comp-020   (/ (* classact-complete 6) 10))
            ;(set comp-gad   (/ (* classact-complete 7) 10))
            ;(set comp-im    (/ (* classact-complete 8) 10))
            ;(set comp-prefs (/ (* classact-complete 9) 10))

            ; has the user installed ClassAct in CLASSACT: ?
            (set @classact-dest (getassign "CLASSACT" "A"))
            (if (= @classact-dest "") (set @classact-dest "SYS:Classes"))

            ; is ClassAct already in SYS:Classes ?
            (if (or (not (exists (tackon @classact-dest "Gadgets/layout.gadget") (noreq)))
                    (= @user-level 2))
                ; no, ask where it should be placed
                (set @classact-dest
                    (askdir
                        (prompt #classdest-prompt)
                        (help #classdest-help)
                        (default @classact-dest)
                        (newpath)
                    )
                )
            )

            ;(complete comp-dest)

            (if (<> (run (cat (tackon @classact-source "C/CheckAssign") " LIBS: " @classact-dest)) 0)
                (
                    (message #noclasses-message)
                    (if (not (exists @classact-dest))
                        (makedir @classact-dest (prompt (cat #creating-dir @classact-dest)))
                    )
                    (set @addassign (cat "Assign >NIL: LIBS: " @classact-dest " ADD\n"))
                    (startup "CLASSACT"
                        (command @addassign)
                        (prompt (cat #adding-1 @classact-dest #adding-2))
                        (help #adding-help)
                    )
                    (run (@addassign))
                )
            )

            ;(complete comp-libs)

            (set @classact-gadgets (tackon @classact-dest "Gadgets"))
            (set @classact-images (tackon @classact-dest "Images"))

            (if (not (exists @classact-gadgets (noreq)))
                (makedir @classact-images
                    (prompt (cat #creating-dir @classact-gadgets))
                )
            )

            (if (not (exists @classact-images (noreq)))
                (makedir @classact-images
                    (prompt (cat #creating-dir @classact-images))
                )
            )

            ;(complete comp-dirs)

            (if (exists "SYS:Classes/Gadgets/button.gadget")
                (if (and (= 2752514 (getversion "SYS:Classes/Gadgets/button.gadget"))
                        (= 4868 (getsize "SYS:Classes/Gadgets/button.gadget")))
                    (if (askbool (prompt #junod-button) (help @askbool-help) (default 1))
                        (
                            (rename "SYS:Classes/Gadgets/button.gadget" "SYS:Classes/Gadgets/button.gadget.v42")
                            (message #junod-backed)
                        )
                        (message #junod-kept)
                    )
                )
            )

            ;(complete comp-junod)

            (if (and (and cpu020 v39) (exists (tackon @classact-source "Classes/Gadgets/layout.gadget.020")))
                (set classes-020 (askbool (prompt #classes-020) (help #help-020) (default 1)))
                (set classes-020 0)
            )

            ;(complete comp-020)

            (set @source-path (tackon @classact-source "Classes/Gadgets"))
            (foreach @source-path "#?.gadget"
                (
                    (set thislib (tackon @source-path @each-name))
                    (if (and classes-020 (exists (cat thislib ".020")))
                        (set thislib (cat thislib ".020"))
                    )
                    (copylib (source thislib)
                        (dest @classact-gadgets)
                        (newname @each-name)
                        (prompt (cat #installing @each-name))
                        (help #classdest-help)
                        (optional "force" "askuser")
                    )
                )
            )

            ;(complete comp-gad)

            (set @source-path (tackon @classact-source "Classes/Images"))
            (foreach @source-path "#?.image"
                (
                    (set thislib (tackon @source-path @each-name))
                    (if (and classes-020 (exists (cat thislib ".020")))
                        (set thislib (cat thislib ".020"))
                    )
                    (copylib (source thislib)
                        (dest @classact-images)
                        (newname @each-name)
                        (prompt (cat #installing @each-name))
                        (help #classdest-help)
                        (optional "force" "askuser")
                    )
                )
            )

            ;(complete comp-im)

            (set @source-path (tackon @classact-source "Classes"))
            (foreach @source-path "#?.class"
                (
                    (set thislib (tackon @source-path @each-name))
                    (if (and classes-020 (exists (cat thislib ".020")))
                        (set thislib (cat thislib ".020"))
                    )
                    (copylib (source thislib)
                        (dest @classact-dest)
                        (newname @each-name)
                        (prompt (cat #installing @each-name))
                        (help #classdest-help)
                        (optional "force" "askuser")
                    )
                )
            )
        )
    )
    (if (exists (tackon @classact-source "Prefs/ClassAct")) ; The archive contains ClassAct prefs tools
        (
            (message #caprefs-message)

            (copylib (source (tackon @classact-source "Prefs/CAPrefs"))
                (dest "C:")
                (prompt (cat #installing "CAPrefs"))
            )
            (copylib (source (tackon @classact-source "Prefs/ClassAct"))
                (dest "SYS:Prefs")
                (prompt (cat #installing "ClassAct Prefs"))
                (infos)
            )

            ;(complete comp-prefs)

            (if (not (exists "ENVARC:ClassAct" (noreq)))
                (
                    (makedir "ENVARC:ClassAct"
                        (prompt (cat #creating-dir "ENVARC:ClassAct"))
                    )
                    (textfile (dest "ENVARC:ClassAct/ClassAct")
                        (append "")
                    )
                )
            )

            (set caprefs-cmd "C:CAPrefs >NIL:\n")
            (startup "CAPREFS"
                (prompt (cat #caprefs-startup-1 caprefs-cmd #caprefs-startup-2))
                (help #caprefs-message)
                (command caprefs-cmd)
            )
        )
    )

    ;(complete classact-complete)
)

; ************** END OF CLASSACT INSTALL PROCEDURE. COPY THE BLOCK ABOVE
; ************** TO YOUR CLASSACT APPLICATION INSTALLER.

; ---------------------------------------------------------------------------
;;;
;;; Install ClassAct
(procedure InstallClassAct
    (UnArc ClassActArc 'InstTemp:' 'Installing the ClassAct GUI system')
    (install-classact)
)
;;;
;;; Configure AmiTCP
(procedure SetupAmiTCP
    (UnarcExtras)
    (CopyLibraries)
    (InstallPPP)
    (SetupDB)
    (SetupBin)
    (MakeEnvs)
    (MakePrefs)
    ; Make directories and assigns
    (makedir (tackon MainDir 'Logs'))
    (makedir 'AmiTCP:usr')
    (makeassign 'INet' 'AmiTCP:')
    (makeassign 'Logs' 'Wirenet:logs')
    (makeassign 'Usr' 'AmiTCP:usr')
    (makedir (tackon 'Usr:' UserName))
    (makeassign 'HOME' (tackon 'Usr:' UserName))

    ; Add assigns to user-startup
    (startup 'Wirenet'
        (prompt '\nI will now add some statements to your user-startup')
        (help '\nThis will add the necessary assigns and paths to your user-startup\n\n' @startup-help)
        (command '    Assign Wirenet: ' InstallPath '\n')
        (command '    Assign AmiTCP:    Wirenet:AmiTCP\n')
        (command '    Assign INet:      AmiTCP:\n')
        (command '    Assign Logs:      Wirenet:Logs\n')
        (command '    Assign Usr:       AmiTCP:usr\n')
        (command '    Assign etc:       AmiTCP:db\n')
        (command '    Assign AWeb3:     Wirenet:AWeb3\n')
        (command '    Assign GUIs:      C: ADD\n')
        (command '    Path Wirenet:bin Wirenet:Thor/bin ADD\n')
        (command '    SetEnv NetState   NoNet\n')
    )
    (run 'path Wirenet:bin ADD')
    (run 'Assign GUIs: C: ADD')
)
;;;
;;;Check to see if Thor is already installed or running
(procedure CheckForThor
    (set GoAhead 'Yes')
    (if (exists 'ENV:Thor')
        (
            (if
                (askbool
                    (prompt ThorInstPrompt)
                    (help ThorInstHelp)
                )
                (
                    (run 'delete ENVARC:Thor all force')
                    (run 'delete ENV:Thor all force')
                )
                (
                    (set GoAhead 'No')
                    (message (cat ExistingThorMsg1 MailUser ExistingThorMsg2))
                )
            )
        )

    )
)
(procedure IsThorRunning
    ; Ensure Thor is not running
    (run 'Avail Flush >NIL:')
    (while (= 20 (run 'ThorInstall:CheckForLib'))
            (
                    (Message '\nThor seems to be running, you MUST close it NOW or the installation will fail!')
                    (run 'Avail Flush >NIL:')
            )
    )
)
;;;
;;; Create directories and setup temporary assigns for convenience
(procedure ThorPaths
    (makedir ThorPath (infos))
    (makedir BBSDataPath (infos))
    (makeassign 'Thor' ThorPath)
    (makeassign 'BBSData' BBSDataPath)
)
;;;
;;; Unarc Thor files
(procedure UnarcThor
    (UnArc ThorMainArc 'InstTemp:' 'Unpacking main Thor files')     ; Unpack main Thor archive
    (makeassign 'ThorInstall' (tackon (expandpath 'InstTemp:') ThorArcDir))     ; Assign ThorInstall:

    ; Unpack inner Thor archive to installation dir then delete it
    (UnArc (tackon 'ThorInstall:' ThorInnerArc) 'Thor:' 'Installing main Thor files')
    (delete (tackon 'ThorInstall:' ThorInnerArc))
    (copyfiles
        (source 'ThorInstall:THOR.macros')
        (dest 'Thor:')
        (nogauge)
    )
    (copyfiles
        (source 'ThorInstall:THOR.readme.info')
        (dest 'Thor:')
        (nogauge)
    )

    ; Unpack inet archive to Thor:
    (UnArc ThorInetArc 'Thor:' 'Unpacking Thor internet files')

    ; Unpack arexx archive to Thor:rexx
    (UnArc ThorArexxArc 'Thor:rexx/' 'Unpacking Thor arexx scripts')
)
;;;
;;; Copy the fonts and icons
(procedure CopyThorFiles
    ; Copy optional fonts
    (copyfiles
        (prompt 'Choose the fonts you want to install with Thor.\nThese are not required for Thor to run.' )
        (help 'This will copy the default font files for Thor.\n\n' @copyfiles-help)
        (source 'ThorInstall:Fonts')
        (dest 'Fonts:')
        (choices
            'Grn'
            'Thin609'
            'Thin611'
            'Thin711'
        )
        (fonts)
        (confirm)
    )
    ; Copy icons
    (if (= IconSet 0)
        (set
            IconPrompt  'Copying icon files'
            IconDir     'ThorInstall:NormalIcons'
            FiletypeDir 'ThorInstall:Filetypes'
            IconWork    '\nCopying icons'
        )
    )
    (if (= IconSet 1)
        (set
            IconPrompt  'Copying MagicWB icon files'
            IconDir     'ThorInstall:MWBIcons'
            FiletypeDir 'ThorInstall:FiletypesMWB'
            IconWork    '\nCopying MagicWB icons'
        )
    )
    (if (= IconSet 2)
        (set
            IconPrompt  'Copying NewIcons icon files'
            IconDir     'ThorInstall:NewIcons'
            FiletypeDir 'ThorInstall:FiletypesNI'
            IconWork    '\nCopying NewIcons'
        )
    )
    ; Copy icon files for Normal, MWB or NewIcons
    (working IconWork)
    (copyfiles
        (prompt IconPrompt)
        (source IconDir)
        (dest 'Thor:')
        (pattern '~(THOR.guide.info)')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'THOR.guide.info')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'ConfigTHOR.guide.info')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'ARexx.guide.info')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'BBSReadRexx.guide.info')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'THOR_Rexx.guide.info')
        (nogauge)
    )
    (copyfiles
        (prompt IconPrompt)
        (source (tackon IconDir 'THOR.guide.info'))
        (dest 'Thor:Docs')
        (newname 'Installation.guide.info')
        (nogauge)
    )
    (makedir 'Thor:Filetypes')
    (copyfiles
        (prompt IconPrompt)
        (source FileTypeDir)
        (dest 'Thor:Filetypes')
        (all)
        (nogauge)
    )
)
;;;
;;; Configure Thor
(procedure ConfigThor
    (working 'Setting up Thor for use with ' ISP)
    ; Create signature file
    (set SigFile (tackon (tackon MainDir 'Thor') 'sig.global'))
    (textfile
        (dest SigFile)
        (append '-- \n')
        (append RealName '  <' MailAddress '>\n')
        (append "Connected via Wirenet - the UK's first Amiga only internet provider")
    )
    ; Create environment variables
    (if (<> 0 (run 'Thor:bin/basemanager convert'))
        (GetOut 'Basemanager failed in setting up the env-variables.')
    )
    ; Fix trailing LF on env vars
    (run 'setenv THOR/THORPath  `getenv THOR/THORPath`')
    (run 'setenv THOR/BBSDataPath `getenv THOR/BBSDataPath`')
    (run 'Copy >NIL: ENV:THOR/#?path ENVARC:THOR')
    ; Copy dummy global.config and extra rexx scripts
    (copyfiles
        (source 'InstTemp:Thor')
        (all)
        (dest 'THOR:')
    )
    ; Set up internet files
    (execute 'thor:s/cfgtcp')
    (execute 'thor:s/cfgtcp_online')
    (execute 'thor:s/cfguucp')

    ; Set icon tooltypes
    (tooltype                                                       ; Set tooltypes for Thor icon
        (dest 'Thor:THOR')
        (settooltype 'FORCETOFRONT' "")
        (settooltype 'SYSTEM' ThorSystem)
    )
    (tooltype                                                       ; Set tooltypes for ConnectThor icon
        (dest 'Thor:ConnectTHOR')
        (settooltype 'SYSTEMNAME' ThorSystem)
    )
    (if (exists 'env:sys/def_drawer.info' (noreq))                  ; Create icon for Docs drawer
        (copyfiles
            (prompt 'Copying default drawer icon')
            (help 'This will copy the default drawer icon.' newline @copyfiles-help)
            (source 'env:sys/def_drawer.info')
            (dest 'Thor:')
            (newname 'Docs.info')
            (infos)
            (nogauge)
        )
    )
    ; Set up news and mail system
    (working 'Setting up a news and mail system for ' RealName ' <' MailAddress '> on ' ISP)
    (run 'Thor:bin/LoadBBSRead')                                    ; Load the bbsread.library
    (run 'WaitForPort BBSREAD')
    (run 'Thor:bin/InitArc')                                        ; Set up archiver types
    (run 'Thor:bin/InitCharsets')                                   ; and CharSets
    (set ConfigConf (cat '\nCONFIGCONF BBSNAME ' tick '"' ThorSystem '"' tick ' CONFNAME ' tick '"EMail"' tick))        ; String for conference config
    (set AddJoin (cat 'WRITEBREVENT BBSNAME ' tick '"' ThorSystem '"' tick ' EVENT EVE_AddJoinCONF STEM NewEvent\n'))   ; String to add AddJoin event
    ; Create Arexx script to set up Thor
    (textfile
        (dest 'InstTemp:ConfigThor.rexx')
        (append '/* Configure Thor to your ' ISP ' account */\n\n')
        (append 'address BBSREAD\n')
        (append '\nGCF_NO_XPK_METHOD    = "00000008"x')
        (append '\nGCF_FILE_SIGNATURE   = "00000010"x')
        (append '\nGCF_IGNORE_KEEPMSG   = "00000001"x')
        (append '\nGCF_IGNORE_KEEPTIME  = "00000002"x')
        (append '\nGCF_ALWAYS_REPLY_STR = "00000100"x')
        (append '\nQT_DEF_SPACE         =  3')
        (append '\nBDF_MARK_OWN_MSGS    = "00000080"x')
        (append '\nCDF_MEMBER_OF        = "00000001"x')
        (append '\nCDF_MAIL             = "00000002"x')
        (append '\nCDF_BBS_KEEPMSG      = "00000200"x')
        (append '\nCDF_BBS_KEEPTIME     = "00000400"x')
        (append '\nCDF_IGNORE_KEEPMSG   = "00000800"x')
        (append '\nCDF_IGNORE_KEEPTIME  = "00001000"x')
        (append '\nCDF_MARK_OWN_MSGS    = "00400000"x')
        (append '\nCDF_ALWAYS_REPLY_STR = "02000000"x')
        (append '\nEVE_AddJoinCONF      = 2')

        ; First the Global bits
        (append (cat'\nCONFIGGLOBAL DNL ' tick '"T:"' tick ' UPL ' tick '"T:"' tick))
        (if (> FreeMem 2500000)
            (append (cat '\nCONFIGGLOBAL BUF 15 BUFSIZE 10240'))    ; Increase buffer sizes if sufficient memory
        )
        (append (cat '\nCONFIGGLOBAL SIG "' SigFile '"'))
        (append '\nCONFIGGLOBAL SET c2x(GCF_NO_XPK_METHOD)')
        (append '\nCONFIGGLOBAL SET c2x(GCF_FILE_SIGNATURE)')
        (append '\nCONFIGGLOBAL SET c2x(GCF_ALWAYS_REPLY_STR)')
        (append '\nCONFIGGLOBAL SET c2x(GCF_IGNORE_KEEPMSG)')
        (append '\nCONFIGGLOBAL CLEAR c2x(GCF_IGNORE_KEEPTIME)')
        (append (cat '\nCONFIGGLOBAL REPLYSTRING ' tick '"On %D, %N said about %S:"' tick))
        (append '\nCONFIGGLOBAL KEEPTIME 604800')

        ; Then the System bits
        (append (cat '\nCONFIGBBS BBSNAME ' tick '"' ThorSystem '"' tick))
        (append (cat ' GRAB ' tick '"' UserName '"' tick))
        (append (cat ' TYPE ' tick '"TCP"' tick))
        (append (cat ' UPLOAD ' tick '"T:"' tick))
        (append (cat ' EMAILADDR ' tick '"' MailAddress '"' tick))
        (append (cat ' USERNAME ' tick '"' RealName '"' tick))
        (append (cat '\nCONFIGBBS BBSNAME ' tick '"' ThorSystem '"' tick))
        (append ' QUOTETYPE QT_DEF_SPACE SET c2x(BDF_MARK_OWN_MSGS)')
        (append '\n')

        ; and then create an EMail conference
        (append (cat ConfigConf ' REPLYSTRING ' tick '"Hello %N, on %D, you said,"' tick ' SET c2x(CDF_MARK_OWN_MSGS)'))
        (append (cat ConfigConf ' SET c2x(CDF_ALWAYS_REPLY_STR)'))
        (append (cat ConfigConf ' CLEAR c2x(CDF_BBS_KEEPTIME)'))
        (append (cat ConfigConf ' CLEAR c2x(CDF_BBS_KEEPMSG)'))
        (append (cat ConfigConf ' SET c2x(CDF_IGNORE_KEEPTIME)'))
        (append (cat ConfigConf ' SET c2x(CDF_IGNORE_KEEPMSG)'))
        (append (cat ConfigConf ' SET c2x(CDF_MEMBER_OF)'))
        (append (cat ConfigConf ' SET c2x(CDF_MAIL)'))
        (append '\n')

        ; Now create AddJoin events for each newsgroup in NewsGroups
        (append 'drop NewEvent.\n')
        (append 'if exists("' NewsGroups '") then do\n')
        (append '    call open(ngfile,"' NewsGroups '","R")\n')
        (append '    do until eof(ngfile)\n')
        (append '        group = word(readln(ngfile),1)\n')
        (append '        if pos(".", group) > 0 then do\n')
        (append '            NewEvent.CONFERENCE = group\n')
        (append '            ' AddJoin)
        (append '            end\n')
        (append '        end\n')
        (append '    end\n')
    )

    (if (<> 0 (run 'rx InstTemp:ConfigThor.rexx'))
        (run 'sys:rexxc/rx InstTemp:ConfigThor.rexx')
    )

    ; Create TCP Config file
    (textfile
        (dest (tackon BBSDataPath 'BBS0/TCPExtConfig'))
        (append ' MailServer ' MailServer ' NewsServer ' NewsServer ' USERNAME ' MailUser ' DELETEMAIL SOCKETS 2\n')
    )
    ; Create UUCP Config file
    ;(textfile
    ;    (dest (tackon BBSDataPath 'BBS0/UUCPExtConfig'))
    ;    (append '3\n')
    ;    (append 'UUNews:\n')
    ;    (append '\n')
    ;    (append 'postnews -f $USER')
    ;    (append '\n')
    ;    (append 'sendmail -f $USER')
    ;)
    ; Create headers file
    (textfile
        (dest (tackon BBSDataPath 'BBS0/.header'))
        (append 'Organization: ' Organisation '\n')
        (append (cat 'X-Installer: Wirenet ' InstVersion '\n'))
    )
)
;;;
;;; Send Welcome messages
(procedure SendWelcome
    (if (exists ThorWelcome (noreq))
        (
            (set MailBox 'InstTemp:ThorWelcome')                ; Create temporary mailbox
            (textfile
                (dest MailBox)
                (append 'From !')
                (append SupportMail)
                (append ' Thu, 1 Feb 96 19:46:57 GMT\n')
                (append 'From: ')
                (append ISP)
                (append ' Support <')
                (append SupportMail)
                (append '>\n')
                (append 'To: ' RealName '<' MailAddress'>\n')
                (append 'Subject: Welcome to Thor\n')
                (append 'X-Mailer: Wirenet installer\n')
                (append '\n')
                (include ThorWelcome)
            )
            (run (cat 'Thor:bin/ParseUUCP ' ThorSystem ' GRAB ' MailBox))
            (delete MailBox)
        )
    )
    (if (exists 'ThorInstall:MIMEmail')
        (run (cat 'Thor:bin/ParseUUCP ' ThorSystem ' GRAB ThorInstall:MIMEmail DELETE'))
    )
)
;;;
;;; Install Thor
(procedure InstallThor
    (message StartThorMsg)
    (CheckForThor)
    (if (= GoAhead 'Yes')
        (
            (set @execute-dir 'RAM:')                               ; to stop arexx script asking for Disk 1
            (ThorPaths)
            (UnarcThor)
            (IsThorRunning)
            (CopyThorFiles)
            (ConfigThor)
            (SendWelcome)
        )
    )
)
;;;
;;; Install AmiFTP
(procedure InstallFTP
    (message StartAmiFtpMsg)
    (UnArc AmiFtpArc 'Wirenet:' 'Installing AmiFTP')                ; Unarc AmiFTP
    ;(copyfiles
    ;    (source 'InstTemp:AmiFTP/AmiFTP')                          ; Copy program
    ;    (dest 'Wirenet:')
    ;    (infos)
    ;)
    (if (not (exists 'Wirenet:AmiFTP/AmiFTP.prefs'))                ; Copy prefs if not already there
        (rename 'Wirenet:AmiFTP/AmiFTP2.prefs' 'Wirenet:AmiFTP/AmiFTP.prefs')
    )
    ;(copyfiles                                                      ; Copy docs
    ;    (source 'InstTemp:AmiFTP/AmiFTP.guide')
    ;    (dest 'Wirenet:doc')
    ;    (infos)
    ;)
    ;(copyfiles
    ;    (source 'InstTemp:AmiFTP/REGISTER')
    ;    (dest 'Wirenet:doc')
    ;    (newname 'AmiFTP.Register')
    ;    (infos)
    ;)
    ;(copyfiles
    ;    (source 'InstTemp:AmiFTP/HISTORY')
    ;    (dest 'Wirenet:doc')
    ;    (newname 'AmiFTP.History')
    ;    (infos)
    ;)
    (if (exists 'REXX:')                                        ; Copy arexx scripts
        (copyfiles
            (source 'Wirenet:AmiFTP/REXX')
            (dest 'REXX:')
            (all)
        )
    )
)
;;;
;;; Install Browser
(procedure InstallBrowser
    (message StartAWebMsg)
    (if (not v39)
        (message NeedOS3forAWeb)
        (
            (makedir 'Wirenet:AWeb3' (infos))
            (makeassign 'AWeb3' 'Wirenet:AWeb3')
            (UnArc AWebArc 'AWeb3:' 'Installing AWeb')      ; Install AWeb in Wirenet:AWeb
            (makedir 'AWeb3:Cache' (infos))                 ; Create cache dir

            (copyfiles                                      ; Install appropriate icons
                (source (tackon 'AWeb3:icons' (select IconSet 'AWeb.info' 'AWeb_MagicWB.info' 'AWeb_NewIcon.info')))
                (dest 'AWeb3:')
                (newname 'AWeb.info')
            )
            (copyfiles                                                      ; Copy large times and courier fonts
                (prompt ' ')
                (help '')
                (source 'AWeb3:Fonts')
                (dest 'FONTS:')
                (all)
                (fonts)
                (nogauge)
            )
            (run 'delete >NIL: AWeb3:Fonts all force')                      ; and delete fonts directory
            (run "SYS:System/FixFonts"
                (confirm)
                (prompt AWebFFPrompt)
                (help AWebFFHelp)
            )
            (working
                (cat '\nConfiguring AWeb for ' RealName ' <' MailAddress '>\n')
            )
            ; copy settings
            (makedir 'ENVARC:AWeb3DEMO')
            (makedir 'ENV:AWeb3DEMO')
            (copyfiles
               (source 'AWeb3:DefaultSettings')
               (dest 'ENVARC:AWeb3DEMO')
               (nogauge)
               (all)
            )
            ; add to settings
            (textfile
                (dest 'ENVARC:AWEB3DEMO/Network')
                (include 'ENVARC:AWEB3DEMO/Network')
                (append (cat 'MNAD ' MailAddress '\n'))
                (append (cat 'MNFN ' RealName '\n'))
                (append (cat 'MNOR ' Organisation '\n'))
                (append (cat 'MNSH ' MailServer '\n'))
                (append (cat 'MNNH ' NewsServer '\n'))
                (append (cat 'MNSI ' SigFile '\n'))
            )

            (copyfiles
               (source 'ENVARC:AWeb3DEMO')
               (dest 'ENV:AWeb3DEMO')
               (all)
               (nogauge)
            )
            (makedir 'AWeb3:T')
            (copyfiles                                      ; Copy default AWeb hotlist
                (prompt '')
                (help '')
                (source 'InstTemp:AWeb/aweb.hotlist')
                (dest 'AWeb3:')
                (nogauge)
            )
            (message AWebHelpMsg)
        )
    )
)
;;;
;;; Install Gui4Cli and other stuff in C:
(procedure InstallGui4Cli
    (copyfiles
        (prompt '\nCopying some necessary files to C:')
        (help
            (cat
                '\nThis will copy some files that are needed by Dashboard '
                'and some of the connection scripts to your C: drawer'
            )
        )
        (source 'InstTemp:c')
        (dest 'C:')
        (all)
    )
)
;;;
;;;Tidy up and quit
(procedure CleanUp
    (working '\n\nJust a bit of tidying up to do now.')
    (makeassign 'ThorInstall')                                      ; Remove temporary assigns
    (makeassign 'Thor')
    (makeassign 'BBSData')
    (makeassign 'InstTemp')
    (if (not (= FromFloppy 'YES'))
        (makeassign 'Wirenet1')
        (makeassign 'Wirenet2')
        (makeassign 'Wirenet3')
    )
    (run 'delete >NIL: Wirenet:InstTempDir all')                    ; Delete installation files
    (run 'delete >NIL:' (cat (tackon drive UnarcTcpDir) '.info'))
    (complete 100)
    (message FinalMsg)
    (message ResetMsg)
    (run (cat 'Multiview ' (tackon InstallPath 'Wirenet.guide')))

    (set @default-dest InstallPath)
)
;;;

;========================== End of Procedures ==========================


;;;============================= Initialise ==============================

(SetParameters)
(SetStrings)
;;;

;;; ========================== Main installation ==========================
(SayHello)
(CheckSystem)
(CheckForAmiTCP)
(ReadEnv)
(complete 10)
(while (GetUserInfo))
(while (GetModemInfo))
(complete 20)
(MakeMainDir)
(InstallAmiTCP)
(complete 30)
(SetupAmiTCP)
(complete 40)
(InstallClassAct)
(complete 50)
(InstallThor)
(complete 60)
(InstallFTP)
(complete 70)
(InstallBrowser)
(complete 80)
(InstallGui4Cli)
(complete 90)
(CleanUp)
;;;
(exit)
