Index: /gsdl/trunk/GSI-Makefile
===================================================================
--- /gsdl/trunk/GSI-Makefile	(revision 18697)
+++ /gsdl/trunk/GSI-Makefile	(revision 18697)
@@ -0,0 +1,117 @@
+###########################################################################
+#
+# GSI-Makefile -- Greenstone Server Interface makefile
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 1999  The New Zealand Digital Library Project
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+test-gsdlhome:
+	@ if test -z "${GSDLHOME}" ; then \
+	  echo "" ; \
+	  echo "Environment variable GSDLHOME not set." ; \
+	  echo "  This needs to be set to run this Makefile target." ; \
+          echo "  Have you run 'source setup.bash'?" ; \
+	  echo "" ; \
+	  exit 1; \
+	else \
+	  echo "Using: " ; \
+	  echo "  GSDLHOME = ${GSDLHOME}" ; \
+	  echo "  GSDLOS   = ${GSDLOS}" ; \
+	fi
+
+configure-cgi: test-gsdlhome
+	@ echo "Configuring cgi-bin/gsdlsite.cfg" ;
+	@ sed "s@\*\*GSDLHOME\*\*@${GSDLHOME}@g" cgi-bin/gsdlsite.cfg.in > cgi-bin/gsdlsite.cfg ;
+
+
+configure-admin: test-gsdlhome
+	@echo "" ;
+	@echo "Configuring admin user password:" ; 
+	encrypted_password=`getpw` ; 
+	if [ $$? = "0" ] ; then \
+	  echo -e "[admin]\n<enabled>true\n<groups>administrator,colbuilder,all-collections-editor\n<password>$$encrypted_password\n<username>admin" \
+             | txt2db -append "${GSDLHOME}/etc/users.db" ; \
+	fi
+	@echo ""
+
+configure-port: test-gsdlhome
+	@ echo "Enter port number to use:"
+	@ ( read port ; \
+	    if test ! -z $$port ; then \
+	      echo "Port: $$port" ; \
+	      echo "Stopping web server (if running)" ; \
+	      make web-stop-tested ; \
+	      echo "Setting config file to use port $$port"; \
+	      cat "${GSDLHOME}/apache-httpd/conf/httpd.conf.in" \
+		| sed "s@\*\*PORT\*\*@$$port@g" \
+		| sed "s@\*\*GSDLHOME\*\*@${GSDLHOME}@g" \
+		> "${GSDLHOME}/apache-httpd/conf/httpd.conf" ; \
+	      echo "Type 'make web-start' to start the web server running on port $$port" ; \
+	    fi ; \
+	    echo "Done" ; )
+
+
+
+MONITOR_SUCCESS="MAKE SUCCESSFUL"
+MONITOR_FAILED="MAKE FAILED"
+MONITOR_FINISHED="MAKE DONE"
+
+configure-apache: test-gsdlhome
+	@ echo "Configuring the apache webserver..." ;
+	@ ( port=`egrep "^apache.port" lib/java/build.properties | awk -F= '{print $$2}'` ; \
+	    echo $$port | make configure-port ; )
+	@ echo $(MONITOR_SUCCESS)
+	@ echo $(MONITOR_FINISHED)
+
+
+configure-web: configure-cgi configure-apache
+
+web-status: test-gsdlhome
+	${GSDLHOME}/apache-httpd/${GSDLOS}/bin/apachectl status
+
+web-start: test-gsdlhome
+	${GSDLHOME}/apache-httpd/${GSDLOS}/bin/apachectl start
+	@ echo $(MONITOR_SUCCESS)
+	@ echo $(MONITOR_FINISHED)
+
+web-restart: test-gsdlhome
+	${GSDLHOME}/apache-httpd/${GSDLOS}/bin/apachectl restart
+	@ echo $(MONITOR_SUCCESS)
+	@ echo $(MONITOR_FINISHED)
+
+web-graceful: test-gsdlhome
+	${GSDLHOME}/apache-httpd/${GSDLOS}/bin/apachectl graceful
+	@ echo $(MONITOR_SUCCESS)
+	@ echo $(MONITOR_FINISHED)
+
+web-stop-tested: 
+	@# This version runs without testing for GSDLHOME
+	@# Useful to be run as a target when we know test-gsdlhome has already
+	@# been done.  This avoids a unnecessary repetition of printing
+	@# out the values of GSDLHOME and GSDLOS
+	@ if test -e "${GSDLHOME}/apache-httpd/conf/httpd.conf" ; then \
+		${GSDLHOME}/apache-httpd/${GSDLOS}/bin/apachectl stop ; \
+	fi
+	@ echo $(MONITOR_SUCCESS)
+	@ echo $(MONITOR_FINISHED)
+
+web-stop: test-gsdlhome web-stop-tested
