5 # Configure Apache web server
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
10 # $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
13 # Source function library and configuration
14 . /etc/plc.d/functions
17 DocumentRoot=/var/www/html
19 httpd_conf=/etc/httpd/conf/httpd.conf
20 ssl_conf=/etc/httpd/conf.d/ssl.conf
21 plc_conf=/etc/httpd/conf.d/plc.conf
25 if [ "$PLC_API_ENABLED" != "1" -a \
26 "$PLC_BOOT_ENABLED" != "1" -a \
27 "$PLC_WWW_ENABLED" != "1" ] ; then
31 MESSAGE=$"Starting web server"
34 # Set the default include path
35 include_path=".:$DocumentRoot/includes:$DocumentRoot/generated:/etc/planetlab/php"
36 sed -i -e "s@;include_path = \"\.:.*\"@include_path = \"$include_path\"@" $php_ini
38 # Disable default Listen directive
39 sed -i -e '/^Listen/d' $httpd_conf
41 # Set the port numbers
42 for server in WWW API BOOT ; do
43 enabled=PLC_${server}_ENABLED
44 if [ "${!enabled}" != "1" ] ; then
47 hostname=PLC_${server}_HOST
48 http_port=PLC_${server}_PORT
49 https_port=PLC_${server}_SSL_PORT
51 # API should always be accessed via SSL
52 if [ "$server" = "API" ] ; then
53 https_port=${!http_port}
57 # Check if we are already listening on these ports
60 for previous_server in WWW API BOOT ; do
61 if [ "$server" = "$previous_server" ] ; then
64 previous_hostname=PLC_${previous_server}_HOST
65 previous_http_port=PLC_${previous_server}_PORT
66 previous_https_port=PLC_${previous_server}_SSL_PORT
68 if [ "${!http_port}" = "${!previous_http_port}" ] ; then
71 if [ "${!https_port}" = "${!previous_https_port}" ] ; then
76 # Listen on these ports
77 if [ $skip_http -eq 0 -a -n "${!http_port}" ] ; then
80 <VirtualHost *:${!http_port}>
81 Redirect /db https://$PLC_WWW_HOST:$PLC_WWW_SSL_PORT/db
82 # XXX Not yet until we can get rid of oldapi
83 # Redirect /$PLC_API_PATH https://$PLC_API_HOST:$PLC_API_PORT/$PLC_API_PATH
87 if [ $skip_https -eq 0 -a -n "${!https_port}" ] ; then
88 # XXX Cannot support NameVirtualHost over SSL. If
89 # the API, boot, and web servers are all running
90 # on the same machine, the web server certificate
93 -e "s/^Listen .*/Listen ${!https_port}/" \
94 -e "s/<VirtualHost _default_:.*>/<VirtualHost _default_:${!https_port}>/" \
99 # Set custom Apache directives
101 if [ "$PLC_API_ENABLED" = "1" ] ; then
103 <Location $PLC_API_PATH>
104 SetHandler python-program
105 PythonPath "sys.path + ['/usr/share/plc_api']"
106 PythonHandler mod_pythonXMLRPC
111 <Location $PLC_API_PATH>
117 if [ "$PLC_WWW_ENABLED" != "1" ] ; then
126 # Make alpina-logs directory writable for bootmanager log upload
127 chown apache:apache $DocumentRoot/alpina-logs/nodes
136 MESSAGE=$"Stopping web server"