#!/bin/sh ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwapachectl.dist,v 1.11 2004/07/12 16:09:52 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the # Free Software Foundation; either version 2, or (at your option) any later # version, or (b) the "Artistic License" which comes with this package. # # 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 either the GNU General Public License or the # Artistic License for more details. ################################################################################ # This is a wrapper for the apachectl utility suitable for use when doing # development on the WeBWorK 2 system. This setup allows each developer to run # an independent Apache server under their own UID, using their own working copy # of the WeBWorK code. ################################################################################ # Configuration ################################################################################ # The path to the Apache binary HTTPD=/usr/local/sbin/httpd # The path to your personal webwork2 directory WEBWORKROOT=$HOME/webwork2 # If you're sharing files with systems being run by other users, uncomment this #umask 2 # Change these only if you need to customize the locations CONFIG=$WEBWORKROOT/conf/devel.apache-config PID=$WEBWORKROOT/logs/httpd.pid GLOBAL=$WEBWORKROOT/conf/global.conf DATABASE=$WEBWORKROOT/conf/database.conf ################################################################################ # Implementation ################################################################################ usage() { echo "$0 { start | stop | restart | graceful | configtest }" } checkpid() { if [ ! -e $PID ]; then echo "$PID: not found. (Perhaps the server is not running?)" exit fi } checknopid() { if [ -e $PID ]; then echo "$PID: exists. (Perhaps the server is already running?)" exit fi } checkconf() { if [ $1.dist -nt $1 ]; then echo "WARNING: "`basename $1.dist`" is newer than "`basename $1`": UPDATE "`basename $1`"!" fi } case $1 in start) checknopid checkconf $GLOBAL checkconf $DATABASE "$HTTPD" -f "$CONFIG" ;; stop) checkpid kill -TERM `cat "$PID"` ;; restart) checkpid checkconf $GLOBAL checkconf $DATABASE kill -HUP `cat "$PID"` ;; graceful) checkpid kill -USR1 `cat "$PID"` checkconf $GLOBAL checkconf $DATABASE ;; configtest) "$HTTPD" -t -f "$CONFIG" ;; *) usage ;; esac