home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / sreinit1.cmd < prev    next >
OS/2 REXX Batch file  |  2000-05-16  |  5KB  |  132 lines

  1. /* SREINIT0.CMD ****************************/
  2. /* start srefilter -- or wait for it to finish resetting */
  3. start_srefilter:
  4. parse arg key_preface,reqnum,verbose,thesem,moreargs,port,gospid,enmadd,sem_maxwait      
  5.  
  6.  
  7. /* this file contains the "static" parameters initialization file */
  8. static_params_file='CFGS\INIT_STA'                /* if no .ext, then port number will be appended */
  9.  
  10. /* or.. you can include init_sta here, and set static_parms_file='' */
  11.  
  12.  
  13. /*************************/
  14.  
  15. /* read the static_params_file */
  16. signal on error name foo1 ; signal on syntax name foo1 ;
  17.  
  18. if static_params_file<>'' then do
  19.     call read_statics
  20.     if result=0 then return 0
  21. end
  22.  
  23. moreargs=loadthreshold||','||backupserverlist||','||delay_seconds||','||message_scramble||','||record_cache_lines||','||logon_limit||','||ssi_extensions
  24. moreargs=moreargs||','ssi_cache_size||','||ssi_cache_duration||','||SSI_CACHE_STAMP||','||no_no_record||','||hit_superuser_suppress||','||pmprintf_opt
  25. MOREARGS=MOREARGS||','||NO_REMOTE_CONFIG||'!!'||custom_inits||'!!'||cgi_post_long_get||','||get_decode_options
  26. moreargs=moreargs||','||never_publicurls||','||digest_auth||','||proxy_cache||','||suppress_gzip_te||','||pre_reply_procedure
  27. moreargs=moreargs||','||delta_encoding_enable||','||delta_encoding_maxsize||','||event_check||','||ce_gzip||','||dynssi_maxage
  28.  
  29.  
  30. /* not in a wait state, hence must be initialize */
  31.    servdir=directory()          /* should NOT be on-the-fly-changeable */
  32.    oo=value(enmadd||'SERVDIR',servdir,'os2environment')
  33.  
  34. /* to avoid trouble, do not allow any other requests while SRE-http is initializing */
  35.   if oo<>"" then do
  36.      cl=extract('clients')
  37.      'response HTTP/1.1 503 Service Unavailable'
  38.      if cl=0 then do
  39.         call pmprintf(' It appears that the SRE-http initialization failed ')
  40.         call pmprintf(' Is your net connection working? ')
  41.         string ' Sorry: Server Initialization Failure. '
  42.         return 0
  43.      end
  44.      else do
  45.          call pmprintf(' 2nd request while initializing: deny access for now ')
  46.      end
  47.      string ' Server is initializing, please try again in a few minutes. '
  48.      return 0
  49.   end
  50.  
  51. /* first call, start up the helper threads ! */
  52.  
  53.   initfilt_file=servdir||"\INITFILT."||port
  54.   aa2=eventsem_close(thesem)
  55.   afilt2=servdir'\srefmon.cmd'
  56.  
  57.   a0=extract('limitclients')
  58.   a1=extract('fastfile')
  59.   a2=extract('limittimewait')
  60.   a3=extract('gmtset')
  61.   a4=server('h')
  62.   servername=servername()
  63.  
  64.   foo=rexxthread('f',afilt2,gospid,thesem,servdir,PORT,servername,enmadd,sem_maxwait,moreargs,key_preface, ,
  65.                  a0,a1,a3,a3,a4)
  66.  
  67.  
  68. /* allow plenty of time for initialization thread to do it's business */
  69.   do forever   /* wait for filter monitor to say "go ahead" */
  70.        if verbose>2 then say " Waiting for activation of " thesem
  71.  
  72.         foo=eventsem_wait(thesem,2000)
  73.         if foo<>0 then do
  74.            call delay(.2)
  75.            iterate
  76.         end
  77.         call pmprintf('SRE-http initialization complete ')
  78.        leave
  79.   end     /* waiting on thesem */
  80.  
  81. return 1
  82.  
  83.  
  84.  
  85. /***********************************/
  86. /* read static parameter files */
  87. read_statics:
  88.  
  89.   if pos('.',static_params_file)=0 then static_params_file=static_params_file'.'port
  90.   jjl=stream(static_params_file,'c','query size')
  91.   if jjl=0 | jjl='' then do
  92.          call pmprintf(' SRE-http ERROR: missing static parameters file: 'static_params_file)
  93.          'string Error. Missing static parameters file: 'static_params_file
  94.          'close'
  95.          return 0
  96.   end
  97.  
  98.   foo=stream(static_params_file,'c','open read')
  99.   if abbrev(translate(foo),'READY')=0 then do
  100.          call pmprintf(' SRE-http ERROR: unable to read static parameters file: 'static_params_file)
  101.          'string Error. Unreadable static parameters file: 'static_params_file
  102.          'close'
  103.          return 0
  104.   end
  105.  
  106.   sstuff=charin(static_params_file,1,jjl)
  107.   foo=stream(static_params_file,'c','close')   
  108.   sstuff=translate(sstuff,'; ','0d0a'x)
  109.   interpret  sstuff
  110.   call pmprintf(' SRE-http: success on reading ' static_params_file)
  111. /* some variables used in srefiltr.80 */
  112.    osse='os2environment'
  113.    dlist='ALWAYS_CHECK_PRIVS BACKUPSERVERLIST LOADTHRESHOLD CGI_BIN_PIECES DIR_CACHE_SIZE ',
  114.            ' DIR_CACHE_DURATION EMPTY_PATH_OKAY HIT_SUPERUSER_SUPPRESS  NCSA_ISMAP CERN_ISMAP NEVER_IMAGEMAPS ' ,
  115.            ' HEAD_TO_GET MAIN_SERVER KEY_PREFACE LOGON_LIMIT NEVER_PUBLICURLS PUT_NO_OVERWRITE ',
  116.            ' PROXY_CACHE QUICK_INTERP QUICK_INTERP_CODE QUICK_REPLACE RANGE_AT_END REALM_1ST_PRIV ',
  117.            ' SSI_EXTENSIONS USER_LOGON_PROC NO_NO_RECORD WILD_SELS_OK ENABLE_ENCRYPTION DEFAULT_ENCRYPTION ',
  118.            ' DELTA_ENCODING_ENABLE DELTA_ENCODING_MAXSIZE EVENT_CHECK CE_GZIP SUPPRESS_GZIP_TE DYNSSI_MAXAGE ' 
  119.    do until dlist=''
  120.         parse var dlist a1 dlist
  121.         avar0=strip(a1)
  122.         aval0=value(avar0)
  123.         foo=value('SREF_'avar0,aval0,osse)
  124.   end
  125. return 1
  126.  
  127.  
  128. foo1:
  129. say "sreinit1 error " sigl " " rc
  130. exit
  131.  
  132.