[19278] | 1 | @echo off
|
---|
| 2 |
|
---|
| 3 | set testdone=0
|
---|
| 4 | set target=%1
|
---|
| 5 | set configfile=%2
|
---|
| 6 |
|
---|
| 7 | set MONITOR_SUCCESS="MAKE SUCCESSFUL"
|
---|
| 8 | set MONITOR_FAILED="MAKE FAILED"
|
---|
| 9 | set MONITOR_FINISHED="MAKE DONE"
|
---|
| 10 |
|
---|
| 11 | :: check that we have >=1 and <=2 arguments
|
---|
| 12 | :chkargs
|
---|
| 13 | if "%target%" == "" goto :usage
|
---|
| 14 | if not "%3" == "" goto :usage
|
---|
| 15 | goto begincmd
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | :usage
|
---|
| 19 | echo.
|
---|
| 20 | echo Usage: %0 command
|
---|
| 21 | echo 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
|
---|
| 27 | echo configure-admin
|
---|
| 28 | echo configure-web [config-filename]
|
---|
| 29 | echo configure-apache [config-filename]
|
---|
| 30 | echo configure-cgi
|
---|
| 31 | ::echo test-gsdlhome
|
---|
| 32 | ::echo web-stop-tested
|
---|
| 33 | echo.
|
---|
| 34 | goto exit
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | :begincmd
|
---|
| 38 | :: web-stop-tested command assumes GSDLHOME/greenstone environment is already set
|
---|
| 39 | if "%target%" == "web-stop-tested" goto stoptest
|
---|
| 40 |
|
---|
| 41 | :: For all other commands, the greenstone environment needs to be set first before they can be run
|
---|
| 42 | :testgsdl
|
---|
| 43 | if NOT "%GSDLHOME%" == "" goto commands
|
---|
| 44 | echo.
|
---|
| 45 | echo Environment variable GSDLHOME not set.
|
---|
| 46 | echo This needs to be set to run the gsicontrol command %target%.
|
---|
| 47 | echo Have you run setup.bat?
|
---|
| 48 | echo.
|
---|
| 49 | goto exit
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | ::MAIN MENU
|
---|
| 53 | :commands
|
---|
| 54 | if "%target%" == "web-start" goto start
|
---|
| 55 | if "%target%" == "web-stop" goto stop
|
---|
| 56 | if "%target%" == "web-restart" goto restart
|
---|
| 57 | if "%target%" == "web-status" goto status
|
---|
| 58 | if "%target%" == "web-graceful" goto graceful
|
---|
| 59 | if "%target%" == "configure-admin" goto cfgadmin
|
---|
| 60 | if "%target%" == "configure-web" goto cfgweb
|
---|
| 61 | if "%target%" == "configure-apache" goto cfgapach
|
---|
| 62 | if "%target%" == "configure-cgi" goto cfgcgi
|
---|
| 63 | if "%target%" == "test-gsdlhome" goto testgsdl
|
---|
| 64 | :: unknown command
|
---|
| 65 | goto usage
|
---|
| 66 |
|
---|
| 67 | :start
|
---|
| 68 | :stop
|
---|
| 69 | :restart
|
---|
| 70 | :status
|
---|
| 71 | :graceful
|
---|
| 72 | :stoptest
|
---|
[19288] | 73 | echo Command %target% is not yet operational (no local apache web server included in this release).
|
---|
[19278] | 74 | goto exit
|
---|
| 75 |
|
---|
| 76 | rem :stoptest
|
---|
| 77 | rem if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\apache-httpd\%GSDLOS%\bin\apachectl" stop
|
---|
| 78 | rem goto exit
|
---|
| 79 |
|
---|
| 80 | ::configure-web
|
---|
| 81 | ::configure-cgi
|
---|
| 82 | :cfgweb
|
---|
| 83 | :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
|
---|
| 89 | echo Configuring cgi-bin\gsdlsite.cfg
|
---|
| 90 | set gsdlpath=%GSDLHOME%
|
---|
| 91 | for /F "delims=*" %%T in ('"echo %gsdlpath%| bin\windows\sed.exe s@\\@\\\\@g"') do set safepath=%%T
|
---|
| 92 | bin\windows\sed.exe "s@\*\*GSDLHOME\*\*@\"%safepath%\"@g" cgi-bin/gsdlsite.cfg.in > cgi-bin/gsdlsite.cfg
|
---|
| 93 | set gsdlpath=
|
---|
| 94 | set safepath=
|
---|
| 95 |
|
---|
| 96 | :cgifin
|
---|
| 97 | echo.
|
---|
| 98 | if "%target%" == "configure-cgi" goto exit
|
---|
| 99 | if "%target%" == "configure-web" goto cfgapach
|
---|
| 100 |
|
---|
| 101 | ::configure-apache
|
---|
| 102 | :cfgapach
|
---|
| 103 | if exist "%GSDLHOME%\llssite.cfg" goto :exit
|
---|
| 104 | if not exist "%GSDLHOME%\llssite.cfg.in" goto :exit
|
---|
| 105 | copy llssite.cfg.in llssite.cfg
|
---|
| 106 | set configfile="%GSDLHOME%\llssite.cfg"
|
---|
| 107 | goto exit
|
---|
| 108 |
|
---|
| 109 | ::configure-admin
|
---|
| 110 | :cfgadmin
|
---|
| 111 | echo.
|
---|
[19288] | 112 | echo Configuring admin user password:
|
---|
| 113 | for /F %%T in ('getpw') do set encrypted_password=%%T
|
---|
[19290] | 114 |
|
---|
| 115 | :: Have to create an intermediate file in the following, because echoing
|
---|
| 116 | :: 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,
|
---|
| 118 | :: but when redirecting to a file, need to escape only once (one hat sign).
|
---|
[19288] | 119 | if ERRORLEVEL 0 (
|
---|
| 120 | (
|
---|
| 121 | echo [admin]
|
---|
[19290] | 122 | echo ^<enabled^>true
|
---|
| 123 | echo ^<groups^>administrator,colbuilder,all-collections-editor
|
---|
| 124 | echo ^<password^>%encrypted_password%
|
---|
| 125 | echo ^<username^>admin
|
---|
| 126 | ) > "%GSDLHOME%\etc\users.txt"
|
---|
| 127 | type "%GSDLHOME%\etc\users.txt" | txt2db -append "%GSDLHOME%\etc\users.gdb"
|
---|
| 128 | del "%GSDLHOME%\etc\users.txt"
|
---|
[19288] | 129 | ) else (
|
---|
| 130 | echo Did not set password
|
---|
| 131 | )
|
---|
| 132 | goto exit
|
---|
[19278] | 133 |
|
---|
[19288] | 134 |
|
---|
[19278] | 135 | :exit
|
---|
| 136 | set testdone=
|
---|
| 137 | set target=
|
---|
| 138 | set configfile=
|
---|
| 139 | set MONITOR_SUCCESS=
|
---|
| 140 | set MONITOR_FAILED=
|
---|
[19288] | 141 | set MONITOR_FINISHED=
|
---|