Index: gsdl/trunk/gsicontrol.bat
===================================================================
--- gsdl/trunk/gsicontrol.bat	(revision 20615)
+++ gsdl/trunk/gsicontrol.bat	(revision 20637)
@@ -39,4 +39,5 @@
 echo    configure-apache [config-filename]
 echo    configure-cgi
+echo    set-port
 echo    test-gsdlhome
 echo    web-stop-tested
@@ -102,11 +103,21 @@
 goto exit
 
+
 :restart
+:: Need to stop server, wait and start it again.
+:: We're using Ping to implement batch file Wait
 if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" %GS2_APACHE_HTTPD_SIGNAL%
-:: wait 4s, see http://malektips.com/dos0017.html. The number in the 2nd line is variable (number of seconds to wait)
-ping 127.0.0.1 -n 2 -w 1000 > nul
-ping 127.0.0.1 -n 4 -w 1000> nul
-::"%GSDLHOME%\bin\windows\starthttpd.exe" %GS2_APACHE_HTTPD_SIGNAL% "%GSDLHOME%\apache-httpd\windows\bin\httpd.exe"
+
+:: Wait 5 seconds and then start. See http://ss64.com/nt/sleep.html (and http://malektips.com/dos0017.html)
+:: if loopback IP address (127.0.0.1) does not exist, we ask them to manually start it up again
+ping -n 1 -w 1000 127.0.0.1 |find "TTL=">nul || goto failmsg
+echo Waiting for re-start....
+ping -n 5 -w 1000 127.0.0.1> nul
 goto start
+
+:failmsg
+echo Unable to wait for restart. Manually run %0 web-start
+goto exit
+
 
 ::status
@@ -184,9 +195,9 @@
 :: See http://ss64.com/nt/for_cmd.html, http://ss64.com/nt/findstr.html (and http://ss64.com/nt/find.html)
 FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^portnumber %configfile%') do set port=%%G
-echo Found port %port%
-FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^externalaccess %configfile%') do set connect=%%G
-
-if "%connect%" == "1" set allowfrom="all"& goto portcon
-FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^host %configfile%') do set allowfrom=%%G
+FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^hostIP %configfile%') do set hostIP=%%G
+FOR /F "tokens=2 delims==" %%G IN ('findstr /R ^externalaccess %configfile%') do set allowfromall=%%G
+
+if "%allowfromall%" == "1" set allowfromall="Allow"& goto portcon
+set allowfromall="Deny"
 
 :: Using CALL to jump to labels means we can return from them. BUT need to ensure
@@ -195,12 +206,14 @@
 goto portcon
 
+
 ::configure-port-and-connection
 :setport
 set /p port=Enter port number to use:
-set /p connect=Allow external connections [yes/no]:
-if "%connect%" == "yes" set allowfrom="all"& goto portcon
-if "%connect%" == "y" set allowfrom="all"& goto portcon
-
-set /p allowfrom=Enter host (hostname, IP, localhost, 127.0.0.1) to use:
+set /p hostIP=Enter host IP to allow (127.0.0.1 is included by default):
+set /p allowfromall=Allow external connections [yes/no]:
+
+if "%allowfromall%" == "yes" set allowfromall="Allow"& goto portcon
+if "%allowfromall%" == "y" set allowfromall="Allow"& goto portcon
+set allowfromall="Deny"
 goto portcon
 
@@ -218,20 +231,17 @@
 if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" "%GSDLHOME%\bin\windows\stophttpd.exe" %GS2_APACHE_HTTPD_SIGNAL% SILENT
 echo Setting config file to use port %port%
-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"
+type "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf.in" | %_sed% "s@\*\*PORT\*\*@%port%@g" | %_sed% "s@\*\*CONNECTPERMISSION\*\*@%allowfromall%@g" | %_sed% "s@\*\*HOST_IP\*\*@%hostIP%@g" | %_sed% "s@\*\*GSDLHOME\*\*@%safepath%@g" | %_sed% "s@\*\*APACHE_HOME_OS\*\*@%safepath%\/apache-httpd\/%GSDLOS%@g" > "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf"
 echo Type '%0 web-start' to start the web server running on port %port%
 echo Done
 
-set connect=
-set allowfrom=
+set allowfromall=
 set _sed=
 set safepath=
+set port=
 
 :: Extra processing for configure-web and configure-cgi command targets
-if not "%target%" == "cfgweb" goto exit
-if not "%target%" == "cfgcgi" goto exit
+if not "%target%" == "configure-web" if not "%target%" == "configure-cgi" goto exit
 if exist "%GSDLHOME%\apache-httpd\%GSDLOS%\conf\httpd.conf" (echo %MONITOR_SUCCESS%) else (echo %MONITOR_FAILED%)
 echo %MONITOR_FINISHED%
-set port=
-set externalaccess=
 goto exit
 
