#!/bin/sh ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwapachectl.dist,v 1.17 2006/05/31 18:25:18 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 # if you want to use SSL, uncomment this line #SSL=-DSSL # Change these only if you need to customize the locations PID=$WEBWORKROOT/logs/httpd.pid CONFIG_GLOBAL=$WEBWORKROOT/conf/global.conf CONFIG_DATABASE=$WEBWORKROOT/conf/database.conf CONFIG_DEVEL=$WEBWORKROOT/conf/devel.apache-config CONFIG_DEVEL_SITE=$WEBWORKROOT/conf/devel-site.apache-config CONFIG_WEBWORK=$WEBWORKROOT/conf/webwork.apache-config CONFIG_THISFILE=$WEBWORKROOT/bin/wwapachectl ################################################################################ # 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 } checkconfs() { for conf in "$@"; do checkconf "$conf" done } 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 checkconfs "$CONFIG_GLOBAL" "$CONFIG_DATABASE" "$CONFIG_DEVEL" "$CONFIG_DEVEL_SITE" "$CONFIG_WEBWORK" "$CONFIG_THISFILE" mkdir -pv "$WEBWORKROOT"/run # hack for httpd.mm "$HTTPD" -f "$CONFIG_DEVEL" -d "$WEBWORKROOT" "$SSL" ;; stop) checkpid kill -TERM `cat "$PID"` ;; restart) checkpid checkconfs "$CONFIG_GLOBAL" "$CONFIG_DATABASE" "$CONFIG_DEVEL" "$CONFIG_DEVEL_SITE" "$CONFIG_WEBWORK" "$CONFIG_THISFILE" kill -HUP `cat "$PID"` ;; graceful) checkpid checkconfs "$CONFIG_GLOBAL" "$CONFIG_DATABASE" "$CONFIG_DEVEL" "$CONFIG_DEVEL_SITE" "$CONFIG_WEBWORK" "$CONFIG_THISFILE" kill -USR1 `cat "$PID"` ;; configtest) "$HTTPD" -t -f "$CONFIG_DEVEL" -d "$WEBWORKROOT" "$SSL" ;; *) usage ;; esac