root/gsdl/trunk/gsicontrol.bat @ 19620

Revision 19290, 4.0 KB (checked in by ak19, 10 years ago)

GSIcontrol.bat's configure-admin now finally works, since it uses an intermediate file to write the updated admin user entry into (redirection to files works, piping straight to txt2db introduces spaces at the end of each line which causes username, password and other key recognitions to fail).

Line 
1@echo off
2
3set testdone=0
4set target=%1
5set configfile=%2
6
7set MONITOR_SUCCESS="MAKE SUCCESSFUL"
8set MONITOR_FAILED="MAKE FAILED"
9set MONITOR_FINISHED="MAKE DONE"
10
11:: check that we have >=1 and <=2 arguments
12:chkargs
13if "%target%" == "" goto :usage
14if not "%3" == "" goto :usage
15    goto begincmd
16
17
18:usage
19echo.
20echo    Usage: %0 command
21echo           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
27echo    configure-admin
28echo    configure-web    [config-filename]
29echo    configure-apache [config-filename]
30echo    configure-cgi
31::echo    test-gsdlhome
32::echo    web-stop-tested
33echo.
34goto exit
35
36
37:begincmd
38:: web-stop-tested command assumes GSDLHOME/greenstone environment is already set
39if "%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
43if 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
54if "%target%" == "web-start" goto start
55if "%target%" == "web-stop" goto stop
56if "%target%" == "web-restart" goto restart
57if "%target%" == "web-status" goto status
58if "%target%" == "web-graceful" goto graceful
59if "%target%" == "configure-admin" goto cfgadmin
60if "%target%" == "configure-web" goto cfgweb
61if "%target%" == "configure-apache" goto cfgapach
62if "%target%" == "configure-cgi" goto cfgcgi
63if "%target%" == "test-gsdlhome" goto testgsdl
64    :: unknown command
65    goto usage
66
67:start
68:stop
69:restart
70:status
71:graceful
72:stoptest
73echo Command %target% is not yet operational (no local apache web server included in this release).
74goto exit
75
76rem :stoptest
77rem if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\apache-httpd\%GSDLOS%\bin\apachectl" stop
78rem goto exit
79
80::configure-web
81::configure-cgi
82:cfgweb
83:cfgcgi
84if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo WARNING: Nothing done for make configure-cgi.
85if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    If you wish to regenerate the file
86if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    %GSDLHOME%\cgi-bin\gsdlsite.cfg
87if exist "%GSDLHOME%\cgi-bin\gsdlsite.cfg" echo    from scratch, delete the existing file first.
88if 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
97echo.
98if "%target%" == "configure-cgi" goto exit
99if "%target%" == "configure-web" goto cfgapach
100
101::configure-apache
102:cfgapach
103if exist "%GSDLHOME%\llssite.cfg" goto :exit
104if 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
111echo.
112echo Configuring admin user password:
113for /F %%T in ('getpw') do set encrypted_password=%%T
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).
119if ERRORLEVEL 0 (
120    (
121    echo [admin]
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" 
129) else (
130    echo Did not set password
131)
132goto exit
133
134
135:exit
136set testdone=
137set target=
138set configfile=
139set MONITOR_SUCCESS=
140set MONITOR_FAILED=
141set MONITOR_FINISHED=
Note: See TracBrowser for help on using the browser.