forked from ubc/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwwapache2ctl.dist
executable file
·110 lines (96 loc) · 3.47 KB
/
wwapache2ctl.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
# $CVSHeader: webwork2/bin/wwapache2ctl.dist,v 1.3 2007/08/13 22:59:50 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/apache2/bin/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/httpd2.pid
CONFIG_GLOBAL=$WEBWORKROOT/conf/defaults.conf
CONFIG_DATABASE=$WEBWORKROOT/conf/database.conf
CONFIG_DEVEL=$WEBWORKROOT/conf/devel.apache2-config
CONFIG_DEVEL_SITE=$WEBWORKROOT/conf/devel-site.apache2-config
CONFIG_WEBWORK=$WEBWORKROOT/conf/webwork.apache2-config
CONFIG_THISFILE=$WEBWORKROOT/bin/wwapache2ctl
################################################################################
# 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" $SSL -d "$WEBWORKROOT" -f "$CONFIG_DEVEL"
;;
stop)
checkpid
kill -TERM `cat "$PID"`
rm -f "$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" $SSL -d "$WEBWORKROOT" -f "$CONFIG_DEVEL" -t
;;
*)
usage
;;
esac