5 # Configure Apache web server
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
10 # $Id: httpd,v 1.3 2006/06/23 20:29:22 mlhuang Exp $
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
21 DocumentRoot=/var/www/html
23 httpd_conf=/etc/httpd/conf/httpd.conf
24 ssl_conf=/etc/httpd/conf.d/ssl.conf
25 plc_conf=/etc/httpd/conf.d/plc.conf
29 if [ "$PLC_API_ENABLED" != "1" -a \
30 "$PLC_BOOT_ENABLED" != "1" -a \
31 "$PLC_WWW_ENABLED" != "1" ] ; then
35 MESSAGE=$"Starting web server"
38 # Set the default include path
39 include_path=".:$DocumentRoot/includes:$DocumentRoot/generated:/etc/planetlab/php"
40 sed -i -e "s@;include_path = \"\.:.*\"@include_path = \"$include_path\"@" $php_ini
42 # Disable default Listen directive
43 sed -i -e '/^Listen/d' $httpd_conf
45 # Set the port numbers
46 for server in WWW API BOOT ; do
47 enabled=PLC_${server}_ENABLED
48 if [ "${!enabled}" != "1" ] ; then
51 hostname=PLC_${server}_HOST
52 http_port=PLC_${server}_PORT
53 https_port=PLC_${server}_SSL_PORT
55 # API should always be accessed via SSL
56 if [ "$server" = "API" ] ; then
57 https_port=${!http_port}
61 # Check if we are already listening on these ports
64 for previous_server in WWW API BOOT ; do
65 if [ "$server" = "$previous_server" ] ; then
68 previous_hostname=PLC_${previous_server}_HOST
69 previous_http_port=PLC_${previous_server}_PORT
70 previous_https_port=PLC_${previous_server}_SSL_PORT
72 if [ "${!http_port}" = "${!previous_http_port}" ] ; then
75 if [ "${!https_port}" = "${!previous_https_port}" ] ; then
80 # Listen on these ports
81 if [ $skip_http -eq 0 -a -n "${!http_port}" ] ; then
84 <VirtualHost *:${!http_port}>
85 Redirect /db https://$PLC_WWW_HOST:$PLC_WWW_SSL_PORT/db
86 # XXX Not yet until we can get rid of oldapi
87 # Redirect /$PLC_API_PATH https://$PLC_API_HOST:$PLC_API_PORT/$PLC_API_PATH
91 if [ $skip_https -eq 0 -a -n "${!https_port}" ] ; then
92 # XXX Cannot support NameVirtualHost over SSL. If
93 # the API, boot, and web servers are all running
94 # on the same machine, the web server certificate
97 -e "s/^Listen .*/Listen ${!https_port}/" \
98 -e "s/<VirtualHost _default_:.*>/<VirtualHost _default_:${!https_port}>/" \
103 # Set custom Apache directives
105 if [ "$PLC_API_ENABLED" = "1" ] ; then
107 <Location $PLC_API_PATH>
108 SetHandler python-program
109 PythonPath "sys.path + ['/usr/share/plc_api']"
110 PythonHandler mod_pythonXMLRPC
115 <Location $PLC_API_PATH>
121 if [ "$PLC_WWW_ENABLED" != "1" ] ; then
130 # Make alpina-logs directory writable for bootmanager log upload
131 chown apache:apache $DocumentRoot/alpina-logs/nodes
133 # Old style PHP constants
134 mkdir -p /etc/planetlab/php
135 cat >/etc/planetlab/php/site_constants.php <<"EOF"
137 include('plc_config.php');
139 define('PL_API_SERVER', PLC_API_HOST);
140 define('PL_API_PATH', PLC_API_PATH);
141 define('PL_API_PORT', PLC_API_PORT);
142 define('PL_API_CAPABILITY_AUTH_METHOD', 'capability');
143 define('PL_API_CAPABILITY_PASS', PLC_API_MAINTENANCE_PASSWORD);
144 define('PL_API_CAPABILITY_USERNAME', PLC_API_MAINTENANCE_USER);
145 define('WWW_BASE', PLC_WWW_HOST);
146 define('BOOT_BASE', PLC_BOOT_HOST);
147 define('DEBUG', PLC_WWW_DEBUG);
148 define('API_CALL_DEBUG', PLC_API_DEBUG);
149 define('SENDMAIL', PLC_MAIL_ENABLED);
150 define('PLANETLAB_SUPPORT_EMAIL', PLC_NAME . ' Support <' . PLC_MAIL_SUPPORT_ADDRESS . '>');
151 define('PLANETLAB_SUPPORT_EMAIL_ONLY', PLC_MAIL_SUPPORT_ADDRESS);
162 MESSAGE=$"Stopping web server"