/* P/390 VM/ESA Starter System Installation program        7/22/95 JAH  */

/*                                                              */
/* 1. Copy or UNZIP VM/ESA volumes from optical disks or CD-ROM */
/* 2. Update DEVMAP drive letters                               */
/* 3. Allocate PAGING, SPOOLS, TDISKS                           */
/* 4. Optionally install MAINT's source disks                   */
/*                                                              */
'@ECHO OFF'
trace o

title = 'VM/ESA PC Server S/390';
titlelong = 'Preconfigured System for VM/ESA';
include = '\VMESA'     /* Source subdirectory */

/* Names and sizes for CP Volumes that will be allocated */
fn1 = 'PAGING.302'
size1 = 15
fn2 = 'TDISKS.303'
size2 = 10
fn3 = 'SPOOLS.304'
size3 = 40
cpvols = (size1+size2+size3)*1048576

Parse upper arg arg1 .

If arg1 = '?' then do
Say 'Correct Form is:'
Say '                 INSTALL [s: [d:]]'
Say '                         ALLOCATE [d:]'
Say ''
Say 'Use this program to install the VM/ESA Starter System from optical disk onto'
Say 'your hard disk. If you do not specify parameters, then you will be prompted'
Say 'for source and destination drive letters. The ALLOCATE function can be used to'
Say 'allocate the PAGING, SPOOLS, and TDISKS volumes if the initial install'
Say 'allocation failed due to insufficent disk space.'
   Exit
   End

/* Load REXXUTIL */
call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
call sysloadfuncs

Parse Source . . sletter':'  /* Find out where INSTALL.CMD is located */

"MODE CO80 32"
Call SysCls
Say ''; Say title 'Installation';
Say '-----------------------------------';
parse upper arg fletter tletter .
If tletter = '' then do
   Say ''; Say 'To continue with installation press Y';
   Say '(any other key to EXIT).';
   parse upper value SysGetKey('NOECHO') with key
   If key<>'Y' Then Exit 1
   End;

/*--------------------------------------------------------------------*/
/* Check for a drive letter(s) passed as parameter to INSTALL */
/*--------------------------------------------------------------------*/
   parse upper arg fletter tletter .   /* from drive, to drive */
   parse var fletter fletter ':' .  /* strip off : if provided */
   parse var tletter tletter ':' .

If fletter='ALLOCATE' then fletter=sletter /* Dummy this out to avoid error message */

If fletter='' then do
   Say '';
   Say 'What disk drive contains the' title 'files?';
   Say 'Type in the letter of the source disk (default = 'sletter').';
   parse upper value SysGetKey('NOECHO') with key
   If key='1B'x Then Do
      Say '*** Nothing installed ***'
      Exit 1
      End
   If key='0D'x Then fletter=sletter;
                Else fletter=key;
   end

If tletter='' then do
   Say '';
   If arg1 = 'ALLOCATE'
     Then Say 'Where do you want to allocate the PAGE, TDSK, and SPOOL files?';
     Else Say 'Where do you want to install the Starter System files?';
   Say 'Type in the letter of the destination disk (default = D).';
   parse upper value SysGetKey('NOECHO') with key
   If key='1B'x Then Do
      Say '*** Nothing installed ***'
      Exit 1
      End
   If key='0D'x Then Do
                    tpath='D:'include;
                    tletter='D';
                    end;
                Else Do
                    tpath=key':'include;
                    tletter=key;
                    end;
   end
Else tpath=tletter':'include;

/* Make sure the drive letters are a single, uppercase alphabetic */
If (length(fletter)<>1 | Datatype(fletter,'U')<>1),
   |(length(tletter)<>1 | Datatype(tletter,'U')<>1) Then do
   Say ''
   Say "Invalid parameters: '"fletter tletter"'. They must be valid OS/2 drive letters."
   Say '*** Nothing installed ***'
   Exit 1;
   End;

fpath = fletter':'include
Log   = tletter':\VM.LOG'
slist = tletter':\VMESA.SIZ' /* Directory list of files that comprise the product */
cmsg  = tletter':\VMESA.MSG' /* Output file for messages from XCOPY & PKUNZIP2 */
Error=0     /* non-zero if any errors */

/* Start the message log entry */
msg='0D0A'x||'===== INSTALL' arg1 'started' Date() Time() '======================================'
x=Lineout(Log,msg); x=Lineout(Log);

/*--------------------------------------------------------------------*/
/* If rerunning for ALLOCATE function, go there directly              */
/*--------------------------------------------------------------------*/
If Strip(arg1) = 'ALLOCATE' then
   Signal Allocate; /* Skip copy and just Allocate PAGING, etc. */

/*--------------------------------------------------------------------*/
/* Check to see if the product has already been installed.            */
/*--------------------------------------------------------------------*/
replace = 0
ee = stream(tpath'\SYSRES.300','C','QUERY EXISTS')
If ee <> '' then Do
   Say '';
   Say '*********************************** WARNING *********************************'
   msg=title 'files are already installed on drive' tpath'\'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   Say 'If you want to REPLACE the existing files then type "Y".'
   Say 'If you want to exit this install then type "N".'
   Do until key = 'Y' | key = 'N'
      parse upper value SysGetKey('NOECHO') with key
      End; /* wait for a Yes or No */
   If key = 'N' then Do
      Say ''
      msg='*** Nothing installed ***'
      Say msg; x=Lineout(Log,msg); x=Lineout(Log);
      Exit 1
      end
   replace = 1   /* means we are replacing existing files */
   End;

   Else do
   Say ''
   Say 'Installing' title 'files on drive' tpath;
   Say '=========================================================';
   End;

/*--------------------------------------------------------------------*/
/*  Check source disk                                                 */
/*--------------------------------------------------------------------*/
d1=0
Disk_1:
finfo = SysDriveInfo(fletter':')
Parse var finfo . . . label
/*        R/W Optical           Base CD               Applic Dev CD */
If label='P390VMESA1 ' | label='P390VMESACD ' | label='P390VMADCD'
Then flabel=label     /* This tells us whether it is a R/W optical or CD-ROM   */
Else do
   If d1=0 then do
     Say ''
     Say 'Insert the "'title'" CD-ROM into drive' fletter'.';
     Say 'and press ENTER to copy programs (any other key to EXIT).';
     end
   Else do
     Call Beep 600,250
     Say ''
     Say 'Incorrect CD-ROM inserted.'
     Say 'Please verify that "'titlelong' CD-ROM"'
     Say 'is in drive' fletter', then press ENTER (any other key to EXIT).'
     end

   parse upper value SysGetKey('NOECHO') with key
   If key<>'0D'x Then do
      Say ''
      msg='*** Nothing installed ***'
      Say msg; x=Lineout(Log,msg); x=Lineout(Log);
      Exit 1
      end
   d1=1
   Signal Disk_1
   End; /* incorrect disk */

/*--------------------------------------------------------------------*/
/* Check free space on the destination disk                           */
/*--------------------------------------------------------------------*/
tinfo = SysDriveInfo(tletter':')
If tinfo = '' then Signal NodiskT
Parse var tinfo . tfree . .

/*--------------------------------------------------------------------*/
/* Check used space on source disk \VMESA subdirectory                */
/*--------------------------------------------------------------------*/
"DIR /N" fpath  ">" slist
If rc <> 0 then do
   Say 'There are no' title 'on disk' fletter':'
   Exit 3
   End;

Numeric Digits 16   /* Allows whole numbers up to 16 digits */
total = 0; copy = ''; zip = 0;
Do While Lines(slist)
   size = 0
   w = Linein(slist)   /* Read a line from the DIR results */
   If Pos('-',w)=3 & Lastpos('-',w)=6 then do  /* looks like a file line */
      Parse upper var w date time size attr name .
      If Datatype(size,'W')=1 then nop  /* Yes, a real file */
         Else Iterate  /* Not a file line */
      Parse var name fn '.' ext .
      If ext = 'ZIP' then do
         call QZIP  /* process PKZIP files */
         zip = zip + 1 /* Flag that there are any Zip files */
         End;
      copy = fpath'\'name copy  /*  Make a list of files to be copied */
      total = total + size
      End;
   End; /* lines */

Call Stream slist,'C','CLOSE'
rc=SysFileDelete(slist)

needed = total + cpvols
If tfree < needed then Signal Nospace1

/*--------------------------------------------------------------------*/
/* Copy the Starter System files and update DEVMAP.1VM                */
/*--------------------------------------------------------------------*/

/* Save any existing DEVMAP file */
devm = tpath'\DEVMAP.1VM'
If stream(devm,'C','QUERY EXISTS') <> '' then do
   Parse var devm name '.' ext
   Say ''
   "COPY" devm name".SAV > nul"
   msg='WARNING: an existing DEVMAP.1VM file has been renamed to' name'.SAV.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   end;

/* Save any existing USER DIRECTORY file */
user = tpath'\USER.DIR'
If stream(user,'C','QUERY EXISTS') <> '' then do
   Parse var user name '.' ext
   Say ''
   "COPY" user name".SAV >nul"
   msg='WARNING: an existing USER.DIR file has been renamed to' name'.SAV.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   end;

Say ''
msg='COPYING' title 'files from 'fpath' to' tpath '...';
Say msg; x=Lineout(Log,msg); x=Lineout(Log);

If zip = 0 then do  /* Fast path - no PKZIP files */
   "XCOPY"  fpath"\*.* " tpath"\";
   If rc <> 0 then Do
     Say '** ERROR copying' fpath'\*.*   See "SYSnnn" message displayed above.'
     msg='** ERROR copying' fpath'\*.*   See "SYSnnn" message that was displayed on the console.'
     x=Lineout(Log,msg); x=Lineout(Log);
     error = error+1
     End; /* error */
   End; /* No PKZIP files  */

Else Do /* Must process PKZIP files */
copycnt= Words(copy)
Do k=1 to copycnt
   filename = Word(copy,k)
   If Right(filename,3) = 'ZIP' Then Do
      Say 'Unzipping' filename
      fletter":\PKUNZIP2 -o -d" filename tpath"\  > " cmsg
      If rc <> 0 then Do
         Say '** ERROR unzipping' filename'. Check' log ' for messages.'
         msg='** ERROR unzipping' filename'. See "(xnn)" messages, below.'
         x=Lineout(Log,msg); x=Lineout(Log);
         error = error+1
         End; /* error */
      End; /* Unzip file */
   Else Do
      Say 'Copying' filename
     "XCOPY"  filename tpath"\  > " cmsg
      If rc <> 0 then Do
         Say '** ERROR copying  ' filename'. See "SYSnnn" message displayed above.'
         msg='** ERROR copying  ' filename'. See "SYSnnn" message that was displayed on the console.'
         x=Lineout(Log,msg); x=Lineout(Log);
         error = error+1
         End; /* error */
      End; /* Xcopy file */
   "COPY" Log"+"cmsg Log">NUL:"   /* append messages to Log */
   End; /* k */
End; /* PKZIP files present */


old = 'D:\VMESA\'
new = tpath'\'
Call UpDEV       /* Update DEVMAP.1VM with destination drive letter */

Say ''

If error<>0 then Do
   msg='Copy of' title 'files is complete, but errors occurred.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   Say 'Check install log' log'.'
   End
Else Do
   msg='Copy of' title 'files is complete.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   Say '------------------------------------------------------'
   End

rc=SysFileDelete(cmsg) /* Done with XCOPY/PKUNZIP message file */

Say 'Press ENTER or any key to continue.'
   parse upper value SysGetKey('NOECHO') with key


/*--------------------------------------------------------------------*/
/* Allocate P/390 CP volumes                                          */
/*--------------------------------------------------------------------*/
Allocate:
/* Re-Load REXXUTIL */
call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
call sysloadfuncs

z=SysSearchPath('PATH','ALC.EXE')
If z = '' then do
   msg='Required program ALC.EXE not found. P/390 Program diskettes must be installed.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   msg='After they are installed, rerun INSTALL ALLOCATE.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   Exit 17;
   end;

Say ''
Say 'Allocating P/390 CP volumes on' tpath'.';
Say '========================================'
Say ''
/*                                          */
/* Check free space on the destination disk */
/*                                          */
cpvols = (size1+size2+size3)*1048576  /* Space needed in bytes */
info = SysDriveInfo(tletter':')
If info = '' then Signal NodiskT
Parse var info . tfree . .
If tfree < cpvols then Signal Nospace2

/*  Make a \VMESA subdirectory  */
rc=SysMkDir(tpath)
If (rc = 0)|(rc = 5) then nop
   Else Signal DirErr;

/*                                          */
/* See if any of the files already exist    */
/*                                          */
file1 = tpath'\'fn1
file2 = tpath'\'fn2
file3 = tpath'\'fn3
state1 = stream(file1,'C','QUERY EXISTS')
state2 = stream(file2,'C','QUERY EXISTS')
state3 = stream(file3,'C','QUERY EXISTS')
If (state1<>'')|(state2<>'')|(state3<>'') then
   Do;
   files=Strip(state1 state2 state3)
   If Words(files) > 1 then
   Do;
      Say 'VM/ESA CP volumes ('files') already exist.'
      Say 'Do you want to replace these files? (Y or N)'
   end;
   Else Do;
      Say 'VM/ESA CP volume ('files') already exists.'
      Say 'Do you want to replace this file? (Y or N)'
   end;
   Do until (key='Y')|(key='N');
      parse upper value SysGetKey('NOECHO') with key
      end;
   If key='Y' Then  /* delete old files */
   Do
      rc=SysFileDelete(file1);
      rc=SysFileDelete(file2);
      rc=SysFileDelete(file3);
      end;
   end;

/*                                                                                */
/* Allocate only those files which are missing or all files if replace was chosen */
/*                                                                                */
Say ''
/* PAGING file */
If (key<>'N')|(state1='') then
   Do
   Say 'Allocating' file1'...';
   'ALC' file1 '/vPAGING /tPAGE /s'size1'M /ESA /q'
   If rc <> 0 then Signal fullpage
   end;

/* TDISK file */
If (key<>'N')|(state2='') then
   Do
   Say 'Allocating' file2'...';
   'ALC' file2 '/vTDISKS /tTDSK /s'size2'M /ESA /q'
   If rc <> 0 then Signal fulltdsk
   end;

/* SPOOL file */
If (key<>'N')|(state3='') then
   Do
   Say 'Allocating' file3'...';
   'ALC' file3 '/vSPOOLS /tSPOL /s'size3'M /ESA /q'
   If rc <> 0 then Signal fulltemp
   end;

If arg1 = 'ALLOCATE' then Signal Exit
Say ''
Say 'Press ENTER or any key to continue.'
      parse upper value SysGetKey('NOECHO') with key


/*                                          */
/* Optionally install VM/ESA Source disks   */
/*==========================================*/
Say ''
Say 'Do you wish to install the VM/ESA source maintenance disks?'
Say 'Press any key to continue, or N key to skip this step.';
Say ''
parse upper value SysGetKey('NOECHO') with key
If key<>'N' Then Do

d3=0
Disk_3:
info = SysDriveInfo(fletter':')
Parse var info . . . label
If label='P390VMSRC ' | label='P390VMESACD ' | label='P390VMADCD'
Then flabel=label     /* This tells us whether it is a R/W optical or CD-ROM   */
Else do
   If d3=0 then do
     Say 'Insert the "VM/ESA P/390 Source" disk'
     Say 'in drive' fletter' and press ENTER to copy programs'
     Say '(any other key to skip).';
     end
   Else do
     Call Beep 600,250
     Say ''
     Say 'Incorrect optical disk inserted.'
     Say 'Please verify that the disk containing VM/ESA source'
     Say 'is inserted in drive' fletter', then press ENTER (any other key to skip).';
     end

   parse upper value SysGetKey('NOECHO') with key
   If key<>'0D'x Then do
      Say ''
      Say '*** VM Source disks NOT installed ***'
      Say 'If you wish to install the VM Source disks in the future,'
      Say 'insert the appropriate disk and type: 'sletter':INSTSRC 'fletter': 'tletter':'
      Say '(or supply any other source and destination drive letters).'
      Signal Exit
      end
   d3=1
   Signal Disk_3
   End; /* incorrect disk */

Say ''
"Call" sletter":\INSTSRC" fletter tletter
End; /* Source install */

Else Do
   Say ''
   Say '*** VM Source disks NOT installed ***'
   Say 'If you wish to install the VM Source disks in the future,'
   Say 'insert the appropriate disk and type: 'sletter':INSTSRC 'fletter': 'tletter':'
   Say '(or supply any other source and destination drive letters).'
   end;


/*                                             */
/* Optionally install VM/ESA Program Products  */
/*=============================================*/

If label='P390VMESACD ' | label='P390VMADCD' then do
Say ''
Say 'Do you wish to install any VM/ESA Program Products?'
Say 'Press any key to continue, or N key to skip this step.';
Say ''
parse upper value SysGetKey('NOECHO') with key
If key<>'N' Then Do

d4=0
Disk_4:
info = SysDriveInfo(fletter':')
Parse var info . . . label
If label='P390VMPP ' | label='P390VMESACD ' | label='P390VMADCD'
Then flabel=label     /* This tells us whether it is a R/W optical or CD-ROM   */
Else do
   If d4=0 then do
     Say 'Insert the "VM/ESA P/390 Program Product" disk'
     Say 'in drive' fletter' and press ENTER to copy programs'
     Say '(any other key to skip).';
     end
   Else do
     Call Beep 600,250
     Say ''
     Say 'Incorrect optical disk inserted.'
     Say 'Please verify that the disk containing VM/ESA Program Products'
     Say 'is inserted in drive' fletter', then press ENTER (any other key to skip).';
     end

   parse upper value SysGetKey('NOECHO') with key
   If key<>'0D'x Then do
      Say ''
      Say '*** VM/ESA Program Products NOT installed ***'
      Say 'If you wish to install the VM/ESA Program Products in the future,'
      Say 'insert the appropriate disk and type: 'sletter':INSTVMPP 'fletter': 'tletter':'
      Say '(or supply any other source and destination drive letters).'
      Signal Exit
      end
   d4=1
   Signal Disk_4
   End; /* incorrect disk */

Say ''
"Call" sletter":\INSTVMPP" fletter tletter
End; /* VMPP install */

Else Do
   Say ''
   Say '*** VM/ESA Program Products NOT installed ***'
   Say 'If you wish to install any VM/ESA Program Products in the future,'
   Say 'insert the appropriate disk and type: 'sletter':INSTVMPP 'fletter': 'tletter':'
   Say '(or supply any other source and destination drive letters).'
   end;
End; /* VMPP install */



Exit:
Say ''
Say title 'installation is complete.'
Say '------------------------------------------------'

Exit 0

/*------********************* ----------------------------------------*/
/*----- S U B R O U T I N E S ----------------------------------------*/
/*------********************* ----------------------------------------*/

QZIP:
/*--------------------------------------------------------------------*/
/* Determine the uncompressed size of a PKZIP file                    */
/*--------------------------------------------------------------------*/
/*  "UNZIP32 -Zt name.ext" gives the following line:

nn files, xxxxxxxx bytes uncompressed, yyyyyy bytes compressed: nn.n%

This routine redirects this "view" output to a file and then parses
the line to extract the xxxxxxxx number of uncompressed bytes.
*/

zlist = tletter":\PKZ.SIZ" /* captured output from unzip32 */
fletter":\UNZIP32 -Zt" fpath"\"name ">" zlist
If rc = 0 then do
   dfound = 0               /* Size found?  */
   Do While Lines(zlist)
      z = Linein(zlist)
      Parse var z . . size .
      size = Strip(size)  /* Just the digits of the size */
      End; /* search all lines */
   Call Stream zlist,'C','CLOSE'
   rc=SysFileDelete(zlist)
   If Datatype(size,'W') = 0 then do
      msg='** ERROR: size for' fpath'\'name ' could not be determined.'
      Say msg; x=Lineout(Log,msg); x=Lineout(Log); /* Log message */
      error = error+1
      End;
   End;
Else do
   msg='** ERROR: size for' fpath'\'name ' could not be determined.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log); /* Log message */
   error = error+1
   End;

Return;
/*------------------------------------------------------------------*/

UpDEV:
idev = tpath'\DEVMAP.1VM';
/*------------------------------------------------------------------*/
/* Update DEVMAP file 'idev' with destination drive letter          */
/* Input: idev = x:\path\devmap.1vm                                 */
/*        old  = y:\oldpath\                                        */
/*        new  = z:\newpath\                                        */
/*------------------------------------------------------------------*/
If stream(idev,'C','QUERY EXISTS') = '' then do
   Say 'ERROR:' idev' file was not found. Rerun INSTALL.'
   Say 'If this error persists, call for service.'
   Exit 1
   end
Parse var idev name '.' ext

odev=name'.TMP'         /* temporary work file   */
rc=SysFileDelete(odev)  /* Erase it if it exists */

dasdlist='3370 3310 0671 9332 9335 9336 FB-5 3375 3380'
totalm=0  /* Count of DASD records modified */

/*                                                               */
/* Search DEVMAP and replace 'old' with 'new' DASD paths         */
/*                                                               */
Do j=0 to 400;
z=charin(idev,1+j*64,64);            /* read a line from devmap */
If length(z)=0 then leave;             /* ..exit if we are done   */

   If ((j=1)|(j=2)|(j=3)|(j=4)) & (substr(z,2,1)=':')
      then z=overlay(tletter,z,1)  /* Password panel filenames */

   If (j=6) & (substr(z,22,1)=':')
      then z=overlay(tletter,z,21)  /* Saved PATH in ENV 2 record */

/* If this is a DASD record, then change the disk drive letter  */
   If Wordpos(substr(z,3,4),dasdlist) <> 0 then
   Do;
   If substr(z,19,1)='*'              /* if it's commented out    */
      then nstart=20                  /* the drive letter is here */
      Else nstart=19                  /* otherwise, it's here     */
   zz=Substr(z,nstart)
   Lrec=Length(Filespec('D',zz)||Filespec('P',zz))
/* Found a match  */
   If Substr(zz,1,Lrec) = old then do
      Lold=Length(old); Lnew=Length(new);
      If Lold=Lnew
      Then do  /* Same length */
         z=overlay(new,z,nstart,Lnew)
         totalm=totalm+1
         end;
      Else do /* Different length */
         /* Find the end of the name (excluding blanks & nulls) */
         eblank=Pos(' ',zz)
         enull=Pos('00'x,zz)
         ename=Min(enull,eblank)
         If ename=0 then ename=Max(enull,eblank)
         old_name=Filespec('N',Substr(zz,1,ename-1))||'00'x
         Loldline=Lold + Length(old_name) /* Total length of existing line     */
         Lnewline=Lnew + Length(old_name) /* Total length of proposed new line */
         If Lnewline <= 33 then do
            If Lnew < Lold then Lnewline=Loldline
            z=overlay(new||old_name,z,nstart,Lnewline)
            totalm=totalm+1
            end
         Else do  /* TOO long to fit - should never happen with Starter System */
            oldline =old||old_name; newline =new||old_name
            Say 'Cannot update' idev ' record "'oldline'" to "'newline'" because length of filename ('Lnewline') is > 33 characters.'
            say ''
            say 'ERROR: Cannot update DEVMAP' idev 'record'
            say '       "'oldline'" to'
            say '       "'newline'"'
            say '       because the resulting filename would be' Lnewline 'characters long,'
            say '       which is greater than the allowable maximum of 33 characters.'
            say ''
            say '       Update of this record will be bypassed. Press ENTER to continue.'
            parse upper value SysGetKey('NOECHO') with key
            say ''
            end; /* Too long to fit */
         End; /* Diff length */
      End; /* Match */
   End; /* This is a DASD record */
   x=charout(odev,z)        /* Write a line to the output file */
End; /* Read thru devmap loop */

/*                          */
/* Done with DEVMAP update  */
/*                          */
x=Lineout(odev);   /* Close file */
x=Lineout(idev);   /* Close file */

msg=totalm 'DASD records modified.'
x=Lineout(Log,msg); x=Lineout(Log);
If totalm > 0 then
    "COPY" odev idev" >NUL:" /* Copy new DEVMAP over the old DEVMAP */
Else If tletter<>'D' then Do  /* no DASD records modified */
   msg='*** Note: DEVMAP could not be updated.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   msg='    Run the P/390 Configurator and check the drive and path for these files.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   End

rc=SysFileDelete(odev)  /* Erase temp file */

/*                                                                   */
/* Run AWSPROF to set this as the active DEVMAP                      */
/*                                                                   */
z=SysSearchPath('PATH','AWSPROF.EXE')
If z = '' then do
   msg='Required program AWSPROF.EXE not found. P/390 Program diskettes must be installed.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   msg='After they are installed, select "P/390 Configuration" icon and specify'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   msg= idev 'for the location of DEVMAP, when prompted.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   Signal EndProf;
   end

"AWSPROF" idev   /* Update OS/2 INI file */
If rc <> 0 then do
   msg='Error updating DEVMAP location.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   end
Else do
   Say ''
   msg=idev 'has been updated and set active.'
   Say msg; x=Lineout(Log,msg); x=Lineout(Log);
   end

EndProf:
Return;

/*------***************************-----------------------------------*/
/*----- E R R O R   R O U T I N E S ----------------------------------*/
/*------***************************-----------------------------------*/

Nospace1:
ndigits=Length(needed);
tdigits=Length(tfree);
tfree=Right(tfree,Max(ndigits,tdigits));
Say ''
msg='** ERROR: Not enough space on drive 'tletter' to install' title
Say msg; x=Lineout(Log,msg);
msg=needed 'bytes ('Trunc(needed/1048576,1) 'MB) are needed on drive 'tletter'.  There are only'
Say msg; x=Lineout(Log,msg);
msg=tfree' bytes ('Trunc(tfree/1048576,1) 'MB) available.'
Say msg; x=Lineout(Log,msg);
Say ''
Say 'Free up enough space on drive 'tletter', or choose a drive that has enough space,'
Say 'and then rerun 'sletter':INSTALL.'
Exit 3


/*                                                      */
/* Don't allow a aborted install to leave partial files */
/*                                                      */
Fulltemp:
  rc=SysFileDelete(file1);
Fulltdsk:
  rc=SysFileDelete(file2);
Fullpage:

Say ''
msg=title 'installation completed, but errors'
Say msg; x=Lineout(Log,msg);
msg='were encountered during the allocation of PAGING, SPOOLS, and TDISKS.'
Say msg; x=Lineout(Log,msg);

Nospace2:
ndigits=Length(cpvols);
tdigits=Length(tfree);
tfree=Right(tfree,Max(ndigits,tdigits));
Say ''
msg=cpvols 'bytes ('Trunc(cpvols/1048576,1) 'MB) of space is required on drive 'tletter'.  There are only'
Say msg; x=Lineout(Log,msg);
msg=tfree' bytes ('Trunc(tfree/1048576,1) 'MB) available.'
Say msg; x=Lineout(Log,msg);
Say ''
Say 'Free up enough space on drive 'tletter', or choose a drive that has enough space,'
Say 'and then rerun 'sletter':INSTALL ALLOCATE.'
Say ''
Exit 3

NodiskF:
Say ''
Say 'Source disk' Fletter': does not exist.  Check parameters and rerun INSTALL.'
Exit 2

NodiskT:
Say ''
Say 'Destination disk' Tletter': does not exist.  Check parameters and rerun INSTALL.'
Exit 2
