Index: /main/trunk/greenstone2/gsicontrol.bat
===================================================================
--- /main/trunk/greenstone2/gsicontrol.bat	(revision 23965)
+++ /main/trunk/greenstone2/gsicontrol.bat	(revision 23966)
@@ -3,4 +3,13 @@
 setlocal
 ::set testdone=0
+set startdir=%CD%
+::cd /d "%~dp0"
+if "%GSDLHOME%" == "" goto testgsdl
+cd "%GSDLHOME%"
+
+::set _sed="%GSDLHOME%\bin\windows\sed.exe"
+:: NOTE: no quotes allowed around the following, since it's used inside 
+:: a FOR statement executing a command already embedded in quotes
+set _sed=bin\windows\sed.exe
 
 set cgibin=cgi-bin
@@ -15,7 +24,6 @@
 :: Construct the signal using the unique GS2 installation
 :: directory (after replacing spaces, colons and backslashes)
-if "%GSDLHOME%" == "" goto testgsdl
 set signal=%GSDLHOME: =_%
-for /F "delims=*" %%T in ('"echo %signal%| bin\windows\sed.exe s@[\\:]@_@g"') do set signal=%%T
+for /F "delims=*" %%T in ('"echo %signal%| %_sed% s@[\\:]@_@g"') do set signal=%%T
 set GS2_APACHE_HTTPD_SIGNAL=GS2_APACHE_HTTPD_%signal%
 set signal=
@@ -50,5 +58,4 @@
 echo    configure-cgi
 echo    reset-gsdlhome [config-filename]
-echo		(Save a copy of %cgibin%\gsdlsite.cfg to preserve any customisations)
 echo    set-port
 echo    test-gsdlhome
@@ -169,14 +176,20 @@
 
 
-:: reset-gsdlhome forces configure-cgi by deleting gsdlsite.cfg
+:: reset-gsdlhome forces configure-cgi by renaming any existing gsdlsite.cfg
 :resethome
 echo.
 if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" (
-	echo **** WARNING. Local changes made to %GSDLHOME%\%cgibin%\gsdlsite.cfg will be lost.
-	del "%GSDLHOME%\%cgibin%\gsdlsite.cfg"
-)
-
-set _sed="bin\windows\sed.exe"
-for /F "delims=*" %%T in ('"echo %GSDLHOME%| bin\windows\sed.exe s@\\@\/@g"') do set safepath=%%T
+	move "%GSDLHOME%\%cgibin%\gsdlsite.cfg" "%GSDLHOME%\%cgibin%\gsdlsite.cfg.bak"	
+	echo **** Regenerating %GSDLHOME%\%cgibin%\gsdlsite.cfg
+	echo **** Previous version of file now %GSDLHOME%\%cgibin%\gsdlsite.cfg.bak
+)
+
+for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\/@g"') do set safepath=%%T
+
+:: Also re-initialise the log4j.properties and Mac's .app files
+
+::set log4jprop=%GSDLHOME%\lib\java\log4j.properties
+::%_sed% "s^@gsdl2home@^%GSDLHOME%^g" "%log4jprop%.in" > "%log4jprop%" 
+type "lib\java\log4j.properties.in" | %_sed% "s\@gsdl2home@\%safepath%\g" > "lib\java\log4j.properties" 
 
 type "gs2-server.app\Contents\document.wflow.in" | %_sed% "s@\*\*GSDLHOME\*\*@%safepath%@g" > "gs2-server.app\Contents\document.wflow"
@@ -194,6 +207,6 @@
 if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" goto cgimsg
 echo Configuring %cgibin%\gsdlsite.cfg
-for /F "delims=*" %%T in ('"echo %GSDLHOME%| bin\windows\sed.exe s@\\@\\\\@g"') do set safepath=%%T
-bin\windows\sed.exe "s@\*\*GSDLHOME\*\*@\"%safepath%\"@g" %cgibin%\gsdlsite.cfg.in > %cgibin%\gsdlsite.cfg	
+for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\\\\@g"') do set safepath=%%T
+%_sed% "s@\*\*GSDLHOME\*\*@\"%safepath%\"@g" %cgibin%\gsdlsite.cfg.in > %cgibin%\gsdlsite.cfg	
 set safepath=
 goto cgifin
@@ -259,10 +272,9 @@
    goto exit
 )
-if "%_sed%" == "" set _sed="bin\windows\sed.exe"
-if "%safepath%" == "" for /F "delims=*" %%T in ('"echo %GSDLHOME%| bin\windows\sed.exe s@\\@\/@g"') do set safepath=%%T
+if "%safepath%" == "" for /F "delims=*" %%T in ('"echo %GSDLHOME%| %_sed% s@\\@\/@g"') do set safepath=%%T
 
 if exist "%GSDLHOME%\%cgibin%\gsdlsite.cfg" FOR /F "tokens=2" %%G IN ('findstr /R ^collecthome "%GSDLHOME%\%cgibin%\gsdlsite.cfg"') do set COLLECTHOME=%%G
 if "%COLLECTHOME%" == "" set COLLECTHOME=%GSDLHOME%\collect
-for /F "delims=*" %%T in ('"echo %COLLECTHOME%| bin\windows\sed.exe s@\\@\/@g"') do set safecollectpath=%%T
+for /F "delims=*" %%T in ('"echo %COLLECTHOME%| %_sed% s@\\@\/@g"') do set safecollectpath=%%T
 
 
@@ -288,3 +300,5 @@
 
 :exit
+cd "%startdir%"
+set startdir= 
 endlocal
Index: /main/trunk/greenstone2/gsicontrol.sh
===================================================================
--- /main/trunk/greenstone2/gsicontrol.sh	(revision 23965)
+++ /main/trunk/greenstone2/gsicontrol.sh	(revision 23966)
@@ -146,10 +146,15 @@
 
 # forces configure-cgi by deleting gsdlsite.cfg
-function reset-gsdlhome {    
+function reset-gsdlhome {
+	echo "" ;
     if test -e "$GSDLHOME/$cgibin/gsdlsite.cfg" ; then
-	echo "**** WARNING. Local changes made to $GSDLHOME/$cgibin/gsdlsite.cfg will be lost.";
-	rm -f "$GSDLHOME/$cgibin/gsdlsite.cfg";
-    fi
-
+		/bin/mv "$GSDLHOME/$cgibin/gsdlsite.cfg" "$GSDLHOME/$cgibin/gsdlsite.cfg.bak" ;
+		echo "**** Regenerating $GSDLHOME/$cgibin/gsdlsite.cfg" ;
+		echo "**** Previous version of file now $GSDLHOME/$cgibin/gsdlsite.cfg.bak" ;
+    fi
+
+	log4jprop=$GSDLHOME/lib/java/log4j.properties
+	sed "s^@gsdl2home@^$GSDLHOME^g" "$log4jprop.in" > "$log4jprop"
+	
     sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" "gs2-server.app/Contents/document.wflow.in" > "gs2-server.app/Contents/document.wflow"
     sed "s@\*\*GSDLHOME\*\*@$GSDLHOME@g" "gli.app/Contents/document.wflow.in" > "gli.app/Contents/document.wflow"
