home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / donkey.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1995-07-28  |  11KB  |  286 lines

  1. /***************************************************************************\
  2. * install.cmd - this installs the Donkey package              950728
  3. *
  4. * Copyright (c) 1995 Martin Lafaix. All Rights Reserved.
  5. \***************************************************************************/
  6.  
  7. signal on halt; trace off
  8.  
  9. /* Load the RexxUtil functions */
  10. Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  11. Call SysLoadFuncs
  12.  
  13. /* Initialisation */
  14. arg opt _
  15. if opt = '-DEBUG' | opt = '/DEBUG' then debug = 1
  16. if opt = '/REMOVE' | opt = '-REMOVE' then signal remove
  17. if opt = '-SAVE' | opt = '/SAVE' then
  18.    parse value _ with file .
  19.  
  20. call ansisetup
  21. say LWhi||BBlu'Abcd'
  22. call header
  23.  
  24. step0:
  25. '@cls'
  26. say '    ┌─────────────────────────────────────────────────────────────────────┐'
  27. say '    │ 'LBro'Step 0'LWhi' - Initialisation                                             │'
  28. say '    └─────────────────────────────────────────────────────────────────────┘'
  29. say      
  30. say '      When you see the following message and want to agree -- that is,'
  31. say '      using the translation table associated with the default code page'
  32. say '      --, what is your answer ?'
  33. say
  34. say BWhi||Blu||sysgetmessage(1745)||LWhi||BBlu
  35. step0a:
  36. call charout ,'      Default answer: 'LGre
  37. pull YES
  38. call charout ,LWhi
  39.  
  40. hlpname = getfilepath(LRed"Donkey"LWhi" Help file", ,
  41.                       "DONKEY.HLP", ,
  42.                       SysSearchPath("HELP","DONKEY.HLP"))
  43.  
  44. startupdir = getfilepath(LRed"Donkey"LWhi" DLL", ,
  45.                          "DONKEYHK.DLL", ,
  46.                          SysSearchPath("PATH", "DONKEYHK.DLL"))
  47. if translate(right(startupdir,12)) = "DONKEYHK.DLL" then
  48.    startupdir = left(startupdir, length(startupdir)-12)
  49. if right(startupdir,1) = "\" then
  50.    startupdir = left(startupdir,length(startupdir)-1)
  51.  
  52. say
  53. say '      Default answer is'LGre YES LWhi
  54. say '      help file is'LGre hlpname LWhi
  55. say '      DLL path is'LGre startupdir LWhi
  56. say
  57. if isnotcorrect() then signal step0a
  58.  
  59. if opt = '/SAVE' | opt = '-SAVE' then
  60.    do
  61.       call lineout file, '/* 'file' - an non-interactive script produced by DONKEY 'date(s)'*/'
  62.       call lineout file
  63.       call lineout file, "Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'"
  64.       call lineout file, "Call SysLoadFuncs"
  65.       call lineout file, 'YES="'YES'"'
  66.       call lineout file, 'hlpname="'hlpname'"'
  67.       call lineout file, 'startupdir="'startupdir'"'
  68.       call lineout file
  69.    end
  70.  
  71. step1:
  72. '@cls'
  73. say '    ┌─────────────────────────────────────────────────────────────────────┐'
  74. say '    │ 'LBro'Step 1'LWhi' - Creating the 'LRed'Donkey Daemon'LWhi' object                          │'
  75. say '    └─────────────────────────────────────────────────────────────────────┘'
  76. say      
  77. say '      A 'LRed'Donkey Daemon'LWhi' object will be added to your startup folder.  If you'
  78. say '      don''t intend to use it -- that is, you don''t want to set the initial'
  79. say '      keyboard state and you don''t want to use 'LRed'Donkey'LWhi'''s special features --'
  80. say '      you don''t have to create it.'
  81. say
  82. call charout ,"      Do you want to create it ? [Y/n] :"
  83. key = ''
  84. do until pos(key,"yYnN"||"0d"x) > 0
  85.    key = SysGetKey("ECHO")
  86.    call charout ,"082008"x
  87. end /* do */
  88. say key
  89. if key ='N' | key = 'n' then signal step2
  90.  
  91. objtitle = "Donkey Daemon"
  92. objdest = '<WP_START>'
  93. objid = '<ML_DONKEYDAEMON>'
  94. helppanel = 4321
  95. parameters = '-gluey:5 -initial:N -lock:shift'
  96. exename = getfilepath(LRed"Donkey Daemon"LWhi, "DK.EXE", SysSearchPath("PATH","DK.EXE"))
  97.  
  98. call createobj
  99.  
  100. call SysOpenObject objid, 'DEFAULT', 0
  101.  
  102. step2:
  103. '@cls'
  104. say '    ┌─────────────────────────────────────────────────────────────────────┐'
  105. say '    │ 'LBro'Step 2'LWhi' - Creating the 'LRed'Donkey'LWhi' object                                 │'
  106. say '    └─────────────────────────────────────────────────────────────────────┘'
  107. say      
  108. say '      A 'LRed'Donkey'LWhi' object will be added to your system setup folder.  It will'
  109. say '      allow you to set the various 'LRed'Donkey'LWhi' settings.'
  110. say
  111.  
  112. objtitle = "Donkey"
  113. objdest = '<WP_CONFIG>'
  114. objid = '<ML_DONKEY>'
  115. helppanel = 10001
  116. parameters = '-answer:'YES
  117. exename = getfilepath(LRed"Donkey"LWhi" object", "DONKEY.EXE", SysSearchPath("PATH","DONKEY.EXE"))
  118.  
  119. call createobj
  120.  
  121. exit
  122.  
  123. isnotcorrect:
  124.    call charout ,"      Is this correct ? [Y/n] :"
  125.    key = ''
  126.    do until pos(key,"yYnN"||"0d"x) > 0
  127.       key = SysGetKey("ECHO")
  128.       call charout ,"082008"x
  129.    end /* do */
  130.    if key = '0d'x then
  131.       say ' '
  132.    else
  133.       say LGre||key||LWhi
  134.    return key = "n" | key = "N"
  135.  
  136. getfilepath: /* arg(1) = title, arg(2) = file name & arg(3) = default path */
  137.    _exename = arg(3)
  138.    say
  139.    say '      Path of the 'arg(1)' ('arg(2)') :'LGre _exename||LWhi
  140.    say
  141.    /* Read the DK.EXE path */
  142.    if isnotcorrect() then _exename = getname(arg(2))
  143.    if translate(right(_exename,length(arg(2)))) \= arg(2) then
  144.       if right(_exename,1) = "\" then
  145.          _exename = _exename||arg(2)
  146.       else
  147.          _exename = _exename"\"arg(2)
  148.    return _exename
  149.  
  150. getname:
  151.    say "      Please enter the complete path for" arg(1)
  152.    do forever
  153.       call charout, "      "LGre
  154.       pull name
  155.       call charout, LWhi
  156.       if translate(right(name,length(arg(1)))) \= arg(1) then
  157.          if right(name,1) = "\" then
  158.             name = name||arg(1)
  159.          else
  160.             name = name"\"arg(1)
  161.       if stream(name,"c","query exists") = '' then
  162.          say "0d0a"x"      The path"LGre name LWhi"is invalid!  Please enter it again."
  163.       else
  164.          leave
  165.    end
  166.    return name
  167.  
  168. createobj:
  169.    /* Create the program object */
  170.    if debug = 1 then
  171.       do
  172.          say
  173.          say '      Creating a program object:'
  174.          say      
  175.          say '              Class = WPProgram'
  176.          say '               Name ='LGre objtitle LWhi
  177.          say '        Destination ='LGre objdest LWhi
  178.          say '         Parameters = PROGTYPE    = PM'
  179.          say '                      EXENAME     ='LGre exename LWhi
  180.          say '                      PARAMETERS  ='LGre parameters LWhi
  181.          say '                      STARTUPDIR  ='LGre startupdir LWhi
  182.          say '                      HELPPANEL   ='LGre helppanel LWhi
  183.          say '                      HELPLIBRARY ='LGre hlpname LWhi
  184.          say '                      OBJECTID    ='LGre objid LWhi
  185.          say '             Option = REPLACE'
  186.          say
  187.          if isnotcorrect() then
  188.             return
  189.       end
  190.    
  191.    if makeobj() then
  192.       say '      Installation successful!  '
  193.    else
  194.       say '      Cannot create Program Object!  Installation failed!'
  195.    return
  196.  
  197. makeobj:
  198.    if opt = '/SAVE' | opt = '-SAVE' then
  199.       do
  200.          call lineout file, 'objtitle="'objtitle'"'
  201.          call lineout file, 'objdest="'objdest'"'
  202.          call lineout file, 'objid="'objid'"'
  203.          call lineout file, 'helppanel="'helppanel'"'
  204.          call lineout file, 'exename="'exename'"'
  205.          call lineout file, 'parameters="'parameters'"'
  206.          call lineout file, 'call SysCreateObject "WPProgram",objtitle,objdest,"OBJECTID="objid";HELPPANEL="helppanel";HELPLIBRARY="hlpname";PARAMETERS="parameters";PROGTYPE=PM;EXENAME="exename";STARTUPDIR="startupdir,"REPLACE"'
  207.          return 1
  208.       end
  209.    else
  210.    return SysCreateObject("WPProgram", ,
  211.                           objtitle, ,
  212.                           objdest, ,
  213.                           "OBJECTID="objid";HELPPANEL="helppanel";HELPLIBRARY="hlpname";PARAMETERS="parameters";PROGTYPE=PM;EXENAME="exename";STARTUPDIR="startupdir, ,
  214.                           "REPLACE")
  215.  
  216. remove:
  217.    call SysDestroyObject('<ML_DONKEYDAEMON>')
  218.    call SysDestroyObject('<ML_DONKEY>')
  219.    exit
  220.  
  221. halt:
  222.    say '0d0a'x'Installation aborted!'
  223.    exit
  224.  
  225. header:
  226.    '@cls'
  227.    say '    ┌─────────────────────────────────────────────────────────────────────┐'
  228.    say '    │                                                                     │'
  229.    say '    │                     'LRed'Donkey'LWhi' installation script                      │'
  230.    say '    │                                                                     │'
  231.    say '    │ You can specify the following command-line options to:              │'
  232.    say '    │                                                                     │'
  233.    say '    │   'LGre'/DEBUG'LWhi'   -   display additional informations when creating objects│'
  234.    say '    │   'LGre'/SAVE f'LWhi'  -   create a REXX script, 'LGre'f'LWhi', which can be used to install│'
  235.    say '    │                'LRed'Donkey'LWhi' in a non-interactive way. It does not actually│'
  236.    say '    │                create objects, it only creates the REXX script.     │'
  237.    say '    │   'LGre'/REMOVE'LWhi'  -   remove 'LRed'Donkey'LWhi'''s objects.                             │'
  238.    say '    │                                                                     │'
  239.    say '    │                                                                     │'
  240.    say '    │ WARNING  --  This script does not move/copy files.  It only creates │'
  241.    say '    │              objects in your desktop.                               │'
  242.    say '    │                                                                     │'
  243.    say '    └─────────────────────────────────────────────────────────────────────┘'
  244.    say '                      (Use Ctrl+C to stop the installation.)'
  245.    parse value SysTextScreenSize() with row col .
  246.    call SysCurPos row-1, 5
  247.    call charout ,LBro'Copyright (c) 1995 Martin Lafaix.'LWhi
  248.    call SysCurPos row-1, col-29
  249.    call charout ,'Press any key to continue...'
  250.    call sysgetkey('noecho')
  251.    return
  252.   
  253. AnsiSetup: /* ANSI control */
  254. Esc=d2c(27)d2c(91)
  255.                                         /* Attributes */
  256. Bli=esc'5m'
  257. Hig=esc'1m'
  258. Non=esc'0m'
  259.                                         /* Foreground colors */
  260. Bla=esc'30m'
  261. Red=esc'31m'
  262. Gre=esc'32m'
  263. Bro=esc'33m'
  264. Blu=esc'34m'
  265. Cya=esc'35m'
  266. Tur=esc'36m'
  267. Whi=esc'37m'
  268. LBla=Hig||esc'30m'
  269. LRed=Hig||esc'31m'
  270. LGre=Hig||esc'32m'
  271. LBro=Hig||esc'33m'
  272. LBlu=Hig||esc'34m'
  273. LCya=Hig||esc'35m'
  274. LTur=Hig||esc'36m'
  275. LWhi=Hig||esc'37m'
  276.                                         /* Background colors */
  277. BBla=esc'40m'
  278. BRed=esc'41m'
  279. BGre=esc'42m'
  280. BBro=esc'43m'
  281. BBlu=esc'44m'
  282. BCya=esc'45m'
  283. BTur=esc'46m'
  284. BWhi=esc'47m'
  285. Return
  286.