home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / bbs102e.zip / install.cmd < prev   
OS/2 REXX Batch file  |  1997-11-16  |  15KB  |  512 lines

  1. /* this is the BBS-addon for  SRE-http installation program */
  2.  
  3. /* Load up advanced REXX functions */
  4. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  5. call SysLoadFuncs
  6.  
  7. /*---- load the rexxlib library */
  8. droprxlib=0 ; gotrxlib=1
  9. foo=rxfuncquery('rexxlibregister')
  10. if foo=1 then do
  11.  droprxlib=1 ; gotrxlib=0
  12.  call rxfuncadd 'rexxlibregister','rexxlib', 'rexxlibregister'
  13.  call rexxlibregister
  14. end
  15. foo=rxfuncquery('rexxlibregister')
  16. if foo=1 then do
  17.     say " Could not find the REXXLIB procedure library (REXXLIB.DLL). "
  18.     say "  Did you download it? "
  19.     exit
  20. end  /* Do */
  21.  
  22. crlf='0d0a'x
  23.  
  24. ansion=checkansi()
  25. if ansion=1 then do
  26.   aesc='1B'x
  27.   cy_ye=aesc||'[37;46;m'
  28.   normal=aesc||'[0;m'
  29.   bold=aesc||'[1;m'
  30.   re_wh=aesc||'[31;47;m'
  31.   reverse=aesc||'[7;m'
  32. end
  33. else do
  34.   say " Warning: Could not detect ANSI....  Install will look ugly ! "
  35.   parse pull .
  36.   cy_ye="" ; normal="" ; bold="" ;re_wh="" ;
  37.   reverse=""
  38. end  /* Do */
  39.  
  40. cls
  41. say  " " ; say
  42.  
  43. call lineout, bold cy_ye
  44. call lineout, "This is the BBS addon for SRE-http  installation program (11/97).     "
  45. call lineout, normal
  46.  
  47. say " This program will ask for the names of a few directories,"
  48. say " and will copy a number of files to these directories."
  49. say "  "
  50.  
  51. if yesno(" Are you ready to continue ")=1 then
  52.  nop
  53. else do
  54.  say " See you later?.. "
  55.  exit
  56. end
  57.  
  58.  
  59. nowdir=directory()
  60. deffil=filespec('d',nowdir)||'\BBSFILES'
  61.  
  62. godir=filespec('d',deffil)||'\GOSERVE'
  63. webdir=filespec('d',deffil)||'\WWW'
  64. addondir=godir||'\ADDON'
  65.  
  66.  
  67. gunky1:
  68. say " "
  69. call charout,  bold " Enter the  root of your BBS-Files directory " normal crlf
  70. call charout,"  ENTER= " deffil  " ? "
  71. parse pull afile_dir
  72. if afile_dir="" then afile_Dir=deffil
  73. afile_dir=strip(afile_dir,'t','\')
  74. foo=dosisdir(afile_dir)
  75. if foo=0 then do
  76.     say " Could not find directory: " afile_dir
  77.     signal gunky1
  78. end
  79.  
  80. gunky2:
  81. say " "
  82. call charout,  bold " Enter the GoServe working directory (that contains SREFILTR.80)" normal crlf
  83. call charout,"  ENTER= " godir  " ? "
  84. parse pull work_dir
  85. if work_dir="" then work_Dir=godir
  86. work_dir=strip(work_dir,'t','\')
  87. foo=dosisdir(work_dir)
  88. if foo=0 then do
  89.     say " Could not find directory: " work_dir
  90.     signal gunky2
  91. end
  92. foo=work_dir||'\SREFILTR.80'
  93. if stream(foo,'c','query exists')=' ' then do
  94.    say " Could not find SREFILTR.80.  Please reenter "
  95.    signal gunky2
  96. end  /* Do */
  97.  
  98. gunky2a:
  99. say " "
  100. call charout,  bold " Enter the SRE-http " normal reverse " addon " normal bold " directory " normal crlf
  101. call charout,"  ENTER= " addondir  " ? "
  102. parse pull addon_dir
  103. if addon_dir="" then addon_Dir=addondir
  104. addon_dir=strip(addon_dir,'t','\')
  105. foo=dosisdir(addon_dir)
  106. if foo=0 then do
  107.     say " Could not find directory: " addon_dir
  108.     signal gunky2a
  109. end
  110.  
  111.  
  112.  
  113. gunky3:
  114. say " "
  115. call charout,  bold " Enter the  GoServe data directory (that contains your home page)" normal crlf
  116. call charout,"  ENTER= " webdir  " ? "
  117. parse pull web_dir
  118. if web_dir="" then web_Dir=webdir
  119. web_dir=strip(web_dir,'t','\')
  120. foo=dosisdir(web_dir)
  121. if foo=0 then do
  122.     say " Could not find directory: " web_dir
  123.     signal gunky3
  124. end
  125.  
  126. gunky4:
  127. say " "
  128. /* check /imgs */
  129. imgdir=web_dir||'\IMGS'
  130. foo=dosisdir(imgdir)
  131. if foo=0 then do
  132.    say " Could not find " imgdir
  133.    call charout,  bold " Enter the  SRE-http /IMGS directory" normal crlf
  134.    call charout,"   ? "
  135.    parse pull imgdir
  136.    imgdir=strip(imgdir,'t','\')
  137.    foo=dosisdir(imgdir)
  138.    if foo=0 then do
  139.     say " Could not find directory: " imgdir
  140.     signal gunky4
  141.   end
  142.   say "Note: you will have to set IMAGEPATH='"|| imgdir ||"'(in BBS.INI) "
  143. end
  144.  
  145.  
  146. bbdir=work_dir||'\bbsdata'
  147.  
  148. say " --------------- "
  149. say " This installation program will install files to " bbdir
  150. say " and to several subdirectories under BBSDATA\.  You can change this by "
  151. say " editing BBS.INI (but I'm  not sure why you'ld want to). "
  152. say " It will also copy a few .HTM (HTML) files to " web_dir
  153. say " "
  154.  
  155. if yesno(" Are you ready to copy the files ")=0 then do
  156.    say " Okay, you can try again later "
  157.    exit
  158. end  /* Do */
  159.     
  160. say "Modifying the BBS.INI file "
  161. goo=charin("BBS.INI",1,chars('bbs.ini'))
  162. aa=stream("BBS.INI",'c','close')
  163.  
  164. todo="file_dir='"||afile_dir||"' "
  165. agoo=pos("file_dir='\BBSFILES'",goo)
  166.  
  167. goo=replacestrg(goo,"file_dir='\BBSFILES'",todo,'ALL')
  168.  
  169. lm="LAST_MODIFIED='"||time('n')' 'date('n')"'"
  170. goo=replacestrg(goo,"LAST_MODIFIED=' '",lm)
  171.  
  172. say " Copying BBS.INI"
  173. t=stream(work_dir||'\BBS.INI','c','query exists')
  174. bbsinifile=t
  175. if t<>" " then do
  176. SAY  REVERSE " -------------------- " NORMAL
  177.  Say " A copy of BBS.INI exists in " work_dir
  178. say " "
  179. say bold "Note to upgraders:" normal " If you are upgrading BBS, we recommend "
  180. say      "                      that you do" bold "not" normal " overwrite BBS.INI. "
  181. say " "
  182.  oo=yesno(" Are you sure you want to overwrite this BBS parameters file ?")
  183.  if oo=1 then do
  184.       arf=dostempname(work_dir||"\BBSINI.???")
  185.       foo=dosrename(t,arf)
  186.       if foo=0 then do
  187.           say " Error renaming " t " to " arf
  188.           exit
  189.       end  /* Do */
  190.       else do
  191.            say " Old copy of BBS.INI moved to " arf
  192.       end  /* Do */
  193.       foo=charout(t,goo,1)
  194.       if foo>0 then do
  195.           say " error writing BBS.INI " foo
  196.           exit
  197.       end  /* Do */
  198.    end  /* Do */
  199.    else do
  200.       say " Old BBS.INI is retained "
  201.    end
  202. SAY  REVERSE " -------------------- " NORMAL
  203.  
  204. end
  205. else do
  206.       foo=charout(work_dir||'\BBS.INI',goo,1)
  207.       bbsinifile=work_dir'\bbs.ini'
  208. end
  209. say " "
  210. say " Copying  BBS.CMD and other stuff to " work_dir ' & ' addon_dir
  211. foo=check_copy('BBS.CMD',addon_dir,' Are you sure (this is the main BBS program file)')
  212. foo=check_copy('BBSCACHE.CMD',work_dir,,1)
  213. foo=check_copy('BBSCONFG.CMD',addon_dir,,1)
  214. foo=check_copy('BBSRECNT.CMD',work_dir,' Are you sure (this is the BBS  recent file lister)',1)
  215. foo=check_copy('BBSUP.CMD',addon_dir,,1)
  216. foo=check_copy('BBSNEWU.CMD',addon_dir,,1)
  217.  
  218. foo=check_copy('BBSHELLO.HTM',web_dir,' Are you sure (this is the BBS "welcome" screen)')
  219. foo=check_copy('BBSLOGON.HTM',web_dir,'Are you sure (this is the BBS "prompt for username/password screen)')
  220. foo=check_copy('BBSUP.HTM',web_dir,'Are you sure (this is the BBS "upload instructions" screen)')
  221. foo=check_copy('BBSNEWU.HTM',web_dir,'Are you sure (this is the BBS "new user registration" screen)')
  222. foo=check_copy('BBSPLAY.HTM',web_dir,' Are you sure (this is the BBS "play with options" front-end)')
  223. foo=check_copy('BBS1A.HTM',web_dir,' Are you sure (this is the first part of the "alternative BBS welcome" screen)')
  224. foo=check_copy('BBS1B.HTM',web_dir,' Are you sure (this is the last  part of the "alternative BBS welcome" screen)')
  225.  
  226.  
  227. say " " ; say " Copy BBS manual (BBS.DOC) to " web_dir
  228. foo=check_copy('BBS.DOC',web_dir,,1)
  229.  
  230. foo=check_copy('*.gif',imgdir,,1)
  231.  
  232. /* create bbsdata directories */
  233. isnew=directory(bbdir)
  234. if isnew="" then do
  235.    say " Creating: " bbdir
  236.    oo=sysmkdir(bbdir)
  237.   if oo=0  then do
  238.           say "      Directory created: " bbdir
  239.   end
  240.   else do
  241.            say "      Could not create " bbdir "(error = " oo
  242.            exit
  243.   end
  244. end
  245. foo=directory(nowdir)
  246. say " "
  247. say " copying generic header, footer, etc. files "
  248. foo=check_copy('BBS.HDR',bbdir,' Are you sure (this is the generic header)')
  249. foo=check_copy('BBS.FTR',bbdir,' Are you sure (this is the generic footer)')
  250. foo=check_copy('BBSZIP.HDR',bbdir,' Are you sure (this is the generic  .ZIP header)')
  251. foo=check_copy('BBS.CTL',bbdir,' Are you sure (this is the access control file)')
  252. foo=check_copy('BBS.EXC',bbdir,' Are you sure (this is the generic exclusion file)')
  253. foo=check_copy('BBS.DSC',bbdir,' Are you sure (this is the generic file-descriptions file)')
  254. foo=check_copy('FILES.BBS',bbdir,' Are you sure (this is the sample inclusion mode file)')
  255.  
  256.  
  257.  
  258. /* create bbsdata directories */
  259. udir=bbdir"\USERLOG"
  260. isnew=directory(udir)
  261. if isnew="" then do
  262.    say " Creating: " udir
  263.    oo=sysmkdir(udir)
  264.   if oo=0  then
  265.           say "      Directory created: " udir
  266.   else do
  267.            say "      Could not create " udir "(error = " oo
  268.            exit
  269.   end
  270. end
  271.  
  272. say " Copying bbsstat.cmd to  " udir
  273. foo=check_copy('BBSSTAT.CMD',strip(udir,'t','\')'\',,1)
  274.  
  275. say " .......... "
  276. /* create bbsdata directories */
  277. udir=bbdir"\UPLOAD"
  278. isnew=directory(udir)
  279. if isnew="" then do
  280.    say " Creating: " udir
  281.    oo=sysmkdir(udir)
  282.   if oo=0  then
  283.           say "      Directory created: " udir
  284.   else do
  285.            say "      Could not create " udir "(error = " oo
  286.            exit
  287.   end
  288. end
  289.  
  290.  
  291. /* create bbsdata directories */
  292. udir=bbdir"\CACHE"
  293. isnew=directory(udir)
  294. if isnew="" then do
  295.    say " Creating: " udir
  296.    oo=sysmkdir(udir)
  297.   if oo=0  then
  298.           say "      Directory created: " udir
  299.   else do
  300.            say "      Could not create " udir "(error = " oo
  301.            exit
  302.   end
  303. end
  304.  
  305. foo=directory(nowdir)
  306.  
  307. say reverse " ------------------------------------------------- "normal
  308. say bold " The BBS files and directories have been created. " normal
  309. say" "
  310. say bold "*" normal " You should now edit " bbsinifile
  311. say      "    -- or read the documentation file (" web_dir||"\BBS.DOC) "
  312. say      "    -- or run the BBS Configurator (/BBSCONFG?) "
  313.  
  314. say " "
  315. say bold "*" normal " The following lines "bold"must"normal" be in your ALIASES.IN file:"
  316. say "         bbs/download/*  bbs?download=* "
  317. say "         bbs/zipdownload/*  bbs?zipdownload=* "
  318. say "     (if they aren't in ALIASES.IN,, you" bold "must"normal" add them) "
  319. say "     (ALIASES.IN is in your SRE-http WORKDATA_DIR; i.e.  D:\GOSERVE\DATA)"
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328. exit
  329.  
  330. /* ------------------------------------------------------------------ */
  331.  /* function: Check if ANSI is activated                               */
  332.  /*                                                                    */
  333.  /* call:     CheckAnsi                                                */
  334.  /*                                                                    */
  335.  /* where:    -                                                        */
  336.  /*                                                                    */
  337.  /* returns:  1 - ANSI support detected                                */
  338.  /*           0 - no ANSI support available                            */
  339.  /*          -1 - error detecting ansi                                 */
  340.  /*                                                                    */
  341.  /* note:     Tested with the German and the US version of OS/2 3.0    */
  342.  /*                                                                    */
  343.  /*                                                                    */
  344.  CheckAnsi: PROCEDURE
  345.    thisRC = -1
  346.  
  347.    trace off
  348.                          /* install a local error handler              */
  349.    SIGNAL ON ERROR Name InitAnsiEnd
  350.  
  351.    "@ANSI 2>NUL | rxqueue 2>NUL"
  352.  
  353.    thisRC = 0
  354.  
  355.    do while queued() <> 0
  356.      queueLine = lineIN( "QUEUE:" )
  357.      if pos( " on.", queueLine ) <> 0 | ,                       /* USA */
  358.         pos( " (ON).", queueLine ) <> 0 then                    /* GER */
  359.        thisRC = 1
  360.    end /* do while queued() <> 0 */
  361.  
  362.  InitAnsiEnd:
  363.  signal off error
  364.  RETURN thisRC
  365.  
  366.  
  367. /* -------------------- */
  368. /* get a yes or no , return 1 if yes */
  369. yesno:procedure expose normal reverse bold
  370. parse arg fooa , allopt,altans
  371. if altans<>" " & words(altans)>1 then do
  372.    w1=strip(word(altans,1))
  373.    w2=strip(word(altans,2))
  374.    a1=left(w1,1) ; a2=left(w2,1)
  375.    a1a=substr(w1,2) ; a2a=substr(w2,2)
  376. end
  377. else do
  378.     a1='Y' ; a1a='es'
  379.     a2='N' ; a2a='o'
  380. end  /* Do */
  381. ayn='  '||bold||a1||normal||a1a||'\'||bold||a2||normal||a2a
  382. if allopt=1 then  ayn=ayn||'\'||bold||'A'||normal||'ll'
  383.  
  384. do forever
  385.  foo1=normal||reverse||fooa||normal||ayn
  386.  call charout,  foo1 normal ':'
  387.  pull anans
  388.  if abbrev(anans,a1)=1 then return 1
  389.  if abbrev(anans,a2)=1 then return 0
  390.  if allopt=1 & abbrev(anans,'A')=1 then return 2
  391. end
  392.  
  393.  
  394. /* ------------- */
  395. /* ----------------------------------------------------------------------- */
  396. /* REPLACESTRG: In string astring, find first occurence substring target and
  397. .   replace it with substring putme
  398. .      if no target, return unchanged astring
  399. .      if no putme, then remove target
  400. .      if type=backward, then find/change LAST occurence
  401. .      if type=all, find/change all occurences
  402. .      if exactmatch=yes, then do not capitalize during search (exact match only */
  403. /* ----------------------------------------------------------------------- */
  404.  
  405. replacestrg: procedure
  406.  
  407. exactmatch=0
  408. backward=0 ; doall=0
  409.  
  410. parse arg astring ,  target   , putme , type , exactmatch
  411.  
  412. type = translate(type)
  413. if type="BACKWARD" then backward="YES"
  414. if type="ALL" then doall="YES"
  415.  
  416. iat=1
  417. joelen=length(target)
  418. joelen2=length(putme)
  419.  
  420. doagain:                /* here if doall=yes */
  421.  if exactmatch="YES" then do
  422.     if   backward="YES" then
  423.         joe= lastpos(target,astring)
  424.     else
  425.         joe= pos(target,astring,iat)
  426.  end
  427.  else do
  428.    if   backward="YES" then
  429.         joe= lastpos(translate(target),translate(astring))
  430.     else
  431.         joe= pos(translate(target),translate(astring),iat)
  432.  end
  433.  if joe=0 then
  434.          return astring
  435.  
  436.  astring=delstr(astring,joe,joelen)
  437.  if putme<>' ' then
  438.     astring=insert(putme,astring,joe-1)
  439.  
  440.  if doall="YES" then do
  441.      iat=joe+joelen2
  442.      signal doagain
  443.  end
  444. /* else, all done */
  445.  return astring
  446.  
  447. /*******************************************/
  448. /* check for existence of file, then ask user to copy or not */
  449. /* note that for X.* type copies, it only checks once
  450.    (not for each file, but just for any one of them */
  451. /********************************************/
  452. check_copy: procedure expose copyall reverse bold normal
  453. parse arg file1, dest1 , amess , noask
  454.  
  455. dest2=strip(dest1,'t','\')||'\'
  456.  
  457. filename=dest2||file1
  458.  
  459.  
  460. if copyall=1 then signal doit3
  461.  
  462.  
  463. aa=sysfiletree(filename,isit,'F')
  464.  
  465. ok=1
  466. if aa<>0 then do
  467.    say " Warning: error when looking for pre-existing copy of: " filename
  468.    ok=yesno(" Do you want to copy this file (or files) anyways? ")
  469.    if ok=1 & amess<>""  then
  470.       ok=yesno(amess)
  471. end
  472.  
  473. if noask=1 then signal doit3
  474.  
  475. if isit.0>0 then do
  476.   if pos('*',file1)=0 then do
  477.       say " "
  478.       say " A file exists with the name: " filename
  479.       ok=yesno(" Do you want to overwrite this file? ",1)
  480.       if ok=1 & amess<>""  then
  481.            ok=yesno(amess)
  482.   end
  483.   else do
  484.     say " "
  485.       say " There is at least one file that matches: " filename
  486.       say "  (this match may " bold " not " normal " be one of the files that will be copied!) "
  487.       ok=yesno(" Do you want to copy these files? ",1)
  488.       if ok=1 & amess<>""  then
  489.            ok=yesno(amess)
  490.   end  /* Do */
  491.  
  492. end
  493.  
  494. if ok=2 then do
  495.   say " "
  496.   say "SRE-http will overwrite all files (not just these) "
  497.   copyall=yesno(" Are you sure you want to do this?")
  498.   if copyall=0 then
  499.       ok=yesno(" Do you want to overwrite the current file (or files)? ")
  500. end
  501.  
  502. if ok=0  then return 0
  503.  
  504. doit3:          /* jump here if copyall is on, or noask=1 */
  505. '@COPY ' file1 dest1 ' > NUL '
  506.  
  507. return 1
  508.  
  509.  
  510.  
  511.  
  512.