Ignore:
Timestamp:
2009-07-08T14:47:08+12:00 (15 years ago)
Author:
ak19
Message:

Added some further commands. portcon now allows one to specify the port and connection. This still needs to be called by the apache configure target. The functionality of gsicontrol isn't complete yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/gsicontrol.bat

    r19290 r19970  
    11@echo off
    22
     3setlocal
    34set testdone=0
    45set target=%1
    56set configfile=%2
    67
    7 set MONITOR_SUCCESS="MAKE SUCCESSFUL"
    8 set MONITOR_FAILED="MAKE FAILED"
    9 set MONITOR_FINISHED="MAKE DONE"
     8:: Need to get greenstone installation directory
     9:: set cwd=%CD%
     10
     11set MONITOR_SUCCESS=MAKE SUCCESSFUL
     12set MONITOR_FAILED=MAKE FAILED
     13set MONITOR_FINISHED=MAKE DONE
    1014
    1115:: check that we have >=1 and <=2 arguments
     
    2024echo    Usage: %0 command
    2125echo           where command is any of the following:
    22 ::echo    web-start
    23 ::echo    web-stop
    24 ::echo    web-restart
    25 ::echo    web-status
    26 ::echo    web-graceful
     26echo    web-start
     27echo    web-stop
     28echo    web-restart
    2729echo    configure-admin
    2830echo    configure-web    [config-filename]
    2931echo    configure-apache [config-filename]
    3032echo    configure-cgi
     33
     34::echo    web-status
     35::echo    web-graceful
    3136::echo    test-gsdlhome
    3237::echo    web-stop-tested
     
    6267if "%target%" == "configure-cgi" goto cfgcgi
    6368if "%target%" == "test-gsdlhome" goto testgsdl
     69if "%target%" == "portcon" goto portcon1
    6470    :: unknown command
    6571    goto usage
    6672
    6773:start
     74"%GSDLHOME%\bin\windows\starthttpd.exe" GS2_APACHE_HTTPD "%GSDLHOME%\apache-httpd\windows\bin\httpd.exe"
     75echo %MONITOR_SUCCESS%
     76echo %MONITOR_FINISHED%
     77goto exit
     78
    6879:stop
     80if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" GS2_APACHE_HTTPD
     81rem if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\apache-httpd\%GSDLOS%\bin\apachectl" stop
     82echo %MONITOR_SUCCESS%
     83echo %MONITOR_FINISHED%
     84goto exit
     85
    6986:restart
     87if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" GS2_APACHE_HTTPD
     88:: wait 2s, see http://malektips.com/dos0017.html. The 2 in the 2nd line is variable
     89ping 127.0.0.1 -n 2 -w 1000 > nul
     90ping 127.0.0.1 -n 2 -w 1000> nul
     91::"%GSDLHOME%\bin\windows\starthttpd.exe" GS2_APACHE_HTTPD "%GSDLHOME%\apache-httpd\windows\bin\httpd.exe"
     92goto start
     93
    7094:status
    7195:graceful
    72 :stoptest
    73 echo Command %target% is not yet operational (no local apache web server included in this release).
     96::echo Command %target% is not yet operational (no local apache web server included in this release).
    7497goto exit
    7598
    76 rem :stoptest
     99:stoptest
     100if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" GS2_APACHE_HTTPD
    77101rem if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\apache-httpd\%GSDLOS%\bin\apachectl" stop
    78 rem goto exit
     102goto exit
    79103
    80104::configure-web
     
    82106:cfgweb
    83107:cfgcgi
    84 if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo WARNING: Nothing done for make configure-cgi.
    85 if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    If you wish to regenerate the file
    86 if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    %GSDLHOME%\cgi-bin\gsdlsite.cfg
    87 if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    from scratch, delete the existing file first.
    88 if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" goto cgifin
     108if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" goto cgimsg
    89109    echo Configuring cgi-bin\gsdlsite.cfg
    90110    set gsdlpath=%GSDLHOME%
     
    93113    set gsdlpath=
    94114    set safepath=
     115    goto cgifin
     116
     117:cgimsg
     118echo WARNING: Nothing done for make configure-cgi.
     119echo    If you wish to regenerate the file
     120echo    %GSDLHOME%\cgi-bin\gsdlsite.cfg
     121echo    from scratch, delete the existing file first.
     122echo.
    95123
    96124:cgifin
    97 echo.
    98125if "%target%" == "configure-cgi" goto exit
    99126if "%target%" == "configure-web" goto cfgapach
     
    115142:: Have to create an intermediate file in the following, because echoing
    116143:: lines straight into a pipe adds spaces before the end of each line.
    117 :: When piping need to double escape angle brackets with three hat signs,
     144:: When piping, need to double-escape the angle brackets with three hat signs,
    118145:: but when redirecting to a file, need to escape only once (one hat sign).
    119146if ERRORLEVEL 0 (
     
    132159goto exit
    133160
     161::configure-port-and-connection
     162:portcon1
     163set /p port=Enter port number to use:
     164set /p connect=Allow external connections [yes/no]:
     165if "%connect%" == "yes" set allowfrom="all" goto portcon2
     166if "%connect%" == "y" set allowfrom="all" goto portcon2
     167set allowfrom="127.0.0.1"
     168
     169:portcon2
     170if "%port%" == "" goto exit
     171    set _sed="bin\windows\sed.exe"
     172    set gsdlpath=%GSDLHOME%
     173    for /F "delims=*" %%T in ('"echo %gsdlpath%| bin\windows\sed.exe s@\\@\/@g"') do set safepath=%%T
     174
     175    echo Port: %port%
     176    echo Stopping web server (if running)
     177    if not exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" echo missing conf file
     178    if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" GS2_APACHE_HTTPD
     179    echo Setting config file to use port %port%
     180bin\windows\sed.exe "s@\*\*GSDLHOME\*\*@\"%safepath%\"@g" cgi-bin/gsdlsite.cfg.in > cgi-bin/gsdlsite.cfg
     181    type "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf.in" | %_sed% "s@\*\*PORT\*\*@%port%@g" | %_sed% "s@\*\*CONNECTION\*\*@%allowfrom%@g" | %_sed% "s@\*\*GSDLHOME\*\*@%safepath%@g" | %_sed% "s@\*\*APACHE_HOME_OS\*\*@%safepath%\/apache-httpd\/%GSDLOS%@g" > "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf"
     182    echo Type '%0 web-start' to start the web server running on port %port%
     183    echo Done
     184    set port=
     185    set connect=
     186    set allowfrom=
     187    set _sed=
     188    set safepath=
     189    set gsdlpath=
     190
    134191
    135192:exit
    136 set testdone=
    137 set target=
    138 set configfile=
    139 set MONITOR_SUCCESS=
    140 set MONITOR_FAILED=
    141 set MONITOR_FINISHED=
     193endlocal
Note: See TracChangeset for help on using the changeset viewer.