home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / os2 / kwq12.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1993-06-24  |  9KB  |  259 lines

  1. /****************************************************************************
  2.  * Copyright Notice:                                                        *
  3.  *  (c) Copyright 1992 by Kurt Westerfeld.  ALL RIGHTS RESERVED.            *
  4.  *      This work protected by US Copyright Law.
  5.  *  You may not create derived works from this material.                    *
  6.  ****************************************************************************
  7.  * $Header: D:\Src\kwqmail\RCS\install.cmd 1.2 1993/06/09 11:28:19 kurt Exp $
  8.  *
  9.  * $Date: 1993/06/09 11:28:19 $
  10.  ****************************************************************************
  11.  * Name:            INSTALL.CMD                                             *
  12.  *                                                                          *
  13.  * Description:     REXX script to install KWQ Mail/2.                      *
  14.  *                                                                          *
  15.  * Usage:           INSTALL <InstallDir> <FloppyDir>                        *
  16.  *                                                                          *
  17.  * Example:         INSTALL C:\KWQMAIL A:                                   *
  18.  ****************************************************************************/
  19.  
  20. /* Register with REXX API extensions. */
  21. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  22. Call SysLoadFuncs
  23. Call SysCls
  24.  
  25. /* Get command line parameters. */
  26. Parse Arg InstallDir FloppyDir
  27.  
  28. /* Initializations. */
  29. bInstructed = 0
  30. Signal On Halt Name SignalHandler
  31.  
  32. /* Get installation directory. */
  33. If InstallDir = " " Then Do
  34.     Call Instructions
  35.     Say
  36.     Call SimplePrompt 'Please enter the directory on your hard drive for KWQ Mail/2:'
  37.     Parse Pull InstallDir
  38.  
  39.     /* Check for errors. */
  40.     If InstallDir = " " Then Do
  41.         Say
  42.         Say 'Error!  You must specify a directory name.'
  43.         Say 'Please re-run this installation program.'
  44.         Say
  45.         Exit
  46.     End
  47. End
  48.  
  49. /* Get directory from which we are installing. */
  50. If FloppyDir = " " Then Do
  51.     Call Instructions
  52.     Say
  53.     Say 'NOTE:  If installing from a floppy drive, specify A: or B: '
  54.     Call SimplePrompt 'Please enter the drive this program is installing from:'
  55.     Pull FloppyDir
  56.  
  57.     /* Check for errors. */
  58.     If FloppyDir = " " Then Do
  59.         Say
  60.         Say 'Error!  You must specify a directory name.'
  61.         Say 'Please re-run this installation program.'
  62.         Say
  63.         Exit
  64.     End
  65. End
  66.  
  67. /* Fix up path. */
  68. If SubStr( FloppyDir, Length( FloppyDir ), 1 ) \= '\' Then
  69.     FloppyDir = FloppyDir||'\'
  70.  
  71. /* Confirm choices. */
  72. Call SysCls
  73. Say
  74. Say '                           KWQ Mail/2 Install!'
  75. Say
  76. Say
  77. Say 'KWQ Mail/2 will be installed with the following information:'
  78. Say
  79. Say '         Installation Directory: "'InstallDir'"'
  80. Say '         Source Directory:       "'FloppyDir'"'
  81. Say
  82. Call YNPrompt 'OK to continue?', '1'
  83.  
  84. /* Check for directory. */
  85. Say
  86. Say 'Checking for directory "'InstallDir'".'
  87. Call SysFileTree InstallDir, FileStem, 'D'
  88.  
  89. /* Directory not found. */
  90. If FileStem.0 = '0' Then Do
  91.     Say 'The "'InstallDir'" directory does not exist on your hard drive.'
  92.     Call YNPrompt 'OK to create "'InstallDir'"?', '1'
  93.     Say 'Creating 'InstallDir'....'
  94.     rc = SysMkDir( InstallDir )
  95.     if rc = 0 Then Do
  96.         Say 'The "'InstallDir'" directory was created successfully.'
  97.     End
  98.     Else Do
  99.         Say 'The "'InstallDir'" directory could not be created.'
  100.         Exit
  101.     End
  102. End
  103.  
  104. /* Copy files. */
  105. Call SysCls
  106. Say
  107. Say 'KWQ Mail/2 INSTALL is copying files to your hard drive.'
  108. Call CopyFile 'kwq.doc',        FloppyDir, InstallDir
  109. Call CopyFile 'kwq.exe',        FloppyDir, InstallDir
  110. Call CopyFile 'kwqmail.HLP',    FloppyDir, InstallDir
  111. Call CopyFile 'bugfixes.doc',   FloppyDir, InstallDir
  112. Call CopyFile 'orderkwq.frm',   FloppyDir, InstallDir
  113. Call CopyFile 'readme.1st',     FloppyDir, InstallDir
  114. Call CopyFile 'taglines.kwq',   FloppyDir, InstallDir
  115. Call CopyFile 'twitfilt.kwq',   FloppyDir, InstallDir
  116. Call CopyFile 'whats.new',      FloppyDir, InstallDir
  117. Call CopyFile 'packing.lst',    FloppyDir, InstallDir
  118.  
  119. /* Prompt to create a program object. */
  120. Call SysCls
  121. Say 'KWQ Mail/2 can be installed as a program object on your desktop.'
  122. Ret = YNPrompt( 'Do you want a program object created?', '0' )
  123. If Ret = 'Y' | Ret = 'y' Then Do
  124.     Say
  125.     Say 'Creating program reference object.'
  126.     r = SysCreateObject(    "WPProgram",,
  127.                             "KWQ Mail/2",,
  128.                             "<WP_DESKTOP>",,
  129.                             "EXENAME="||InstallDir||"\KWQ.EXE;ASSOCTYPE=,QWK Mail;ASSOCFILTER=*.QWK;STARTUPDIR="||InstallDir )
  130. End
  131.  
  132. /* Salutation! */
  133. Call SysCls
  134. Say 'KWQ Mail/2 has been installed on your system.'
  135. Say
  136. Say 'Be sure to browse the "README.1ST" file for information about'
  137. Say 'last minute changes to the documentation.'
  138. Say
  139. Call SimplePrompt 'Press the Enter key to exit installation....'
  140. Pull ByeBye
  141.  
  142. /* Bye! */
  143. Exit
  144.  
  145.  
  146. /****************************************************************************
  147.  * Name:        CopyFile
  148.  *
  149.  * Description: Procedure to copy a file from one place to another.
  150.  *
  151.  * Args:        File2copy, FloppyDrive, DestDrive
  152.  ****************************************************************************/
  153. CopyFile: Arg ArgFile2Copy, ArgFloppyDir, ArgInstallDir
  154.  
  155.     Say
  156.     Say 'Copying 'ArgFloppyDir||ArgFile2Copy' to 'ArgInstallDir||'\'||ArgFile2Copy'.'
  157.     Command = '@Copy 'ArgFloppyDir||ArgFile2Copy' 'ArgInstallDir||'\'||ArgFile2Copy
  158.     Command
  159.     if rc \= 0 Then Do
  160.         Call SimplePrompt 'Error! 'ArgFile2Copy' was not installed properly.'
  161.         Pull ConfirmIt
  162.     End
  163.     Return
  164.  
  165.  
  166. /****************************************************************************
  167.  * Name:        Prompt
  168.  *
  169.  * Description: Procedure to place a prompt onto the screen a reposition the
  170.  *              cursor.
  171.  *
  172.  * Args:        Prompt
  173.  ****************************************************************************/
  174. SimplePrompt: Parse Arg ArgPrompt
  175.  
  176.     /* Get current cursor position. */
  177.     Parse Value SysCurPos() With Row .
  178.  
  179.     /* Get screen size. */
  180.     Parse Value SysTextScreenSize() With NumRows .
  181.  
  182.     /* At end of screen? */
  183.     if Row = NumRows - 1 Then Row = Row - 1
  184.  
  185.     /* Assemble prompt. */
  186.     Col = Length( ArgPrompt ) + 1
  187.  
  188.     /* Show prompt. */
  189.     Say ArgPrompt
  190.     Call SysCurPos Row, Col
  191.  
  192.     Return
  193.  
  194.  
  195. /****************************************************************************
  196.  * Name:        YNPrompt
  197.  *
  198.  * Description: Procedure to prompt for Yes or No.
  199.  *              Exit program if No is pressed and Abort is '1'.
  200.  *
  201.  * Args:        Yes/No Prompt
  202.  ****************************************************************************/
  203. YNPrompt: Parse Arg ArgPrompt, ArgAbort
  204.  
  205.     /* Prompt the user. */
  206.     Call SimplePrompt ArgPrompt' (Y or N)'
  207.  
  208.     /* Loop until user presses y or n. */
  209.     Do Forever
  210.         Key = SysGetKey( 'NOECHO' )
  211.         If Key = 'Y' | Key = 'y' Then Do
  212.             Say
  213.             Return Key
  214.         End
  215.         Else If Key = 'N' | Key = 'n' Then Do
  216.             Say
  217.             If ArgAbort = '1' Then Exit
  218.             Return Key
  219.         End
  220.     End
  221.     Return 'y'
  222.  
  223.  
  224. /****************************************************************************
  225.  * Name:        Instructions
  226.  *
  227.  * Description: Instruct the user how this installation will work.
  228.  ****************************************************************************/
  229. Instructions:
  230.     If bInstructed  = 0 Then Do
  231.         Say
  232.         Say '                   KWQ Mail/2 Installation Instructions:'
  233.         Say
  234.         Say
  235.         Say 'Directions:    To install KWQ Mail/2, you must choose a target'
  236.         Say '               directory on your hard drive and enter the name'
  237.         Say '               of the floppy drive this batch file is'
  238.         Say '               executing from.'
  239.         Say
  240.         Say 'Optional:      INSTALL <InstallDir> <FloppyDir> '
  241.         Say
  242.         Say 'Example:       INSTALL C:\KWQMAIL A: '
  243.         Say
  244.         bInstructed = 1
  245.     End
  246.     Return
  247.  
  248.  
  249. /****************************************************************************
  250.  * Name:        SignalHandler
  251.  *
  252.  * Description: Default signal handler.
  253.  ****************************************************************************/
  254. SignalHandler:
  255.     Call SysCls
  256.     Say 'KWQ Mail/2 installation aborted.'
  257.     Exit
  258.  
  259.