Commit 32cc8aa4 authored by Francois Marier's avatar Francois Marier
Browse files

Split up the Apache config file

There are now three apache config files:
- /etc/mahara/apache.conf
- /etc/mahara/servername.conf
- /etc/mahara/serverredirects.conf

The last two are managed by debconf (overwritten at configure time) and are included in the first one.

/etc/mahara/apache.conf is marked as a config file and is meant to be edited by users.  It is symlinked into /etc/apache2/conf.d/mahara or /etc/apache/conf.d/mahara.

WR#1274
parent 0bdaa82f
<VirtualHost *>
ServerName __SERVERNAME__
Include /etc/mahara/servername.conf
DocumentRoot /var/www/mahara
......@@ -32,3 +32,4 @@
</Location>
</VirtualHost>
Include /etc/mahara/serverredirects.conf
etc/mahara
var/www/mahara
usr/share/mahara
var/lib/mahara
var/lib/mahara/smarty/compile
htdocs/* var/www/mahara
htdocs/.htaccess var/www/mahara
debian/apache.conf.template usr/share/mahara/
debian/servername.conf etc/mahara/
debian/serverredirects.conf etc/mahara/
debian/config.debconf.php etc/mahara/
var/www/mahara/js/MochiKit/Packed.js var/www/mahara/js/MochiKit/setup.js
etc/mahara/config.debconf.php var/www/mahara/config.debconf.php
etc/mahara/config.php var/www/mahara/config.php
links
\ No newline at end of file
var/www/mahara/js/MochiKit/Packed.js var/www/mahara/js/MochiKit/setup.js
etc/mahara/config.debconf.php var/www/mahara/config.debconf.php
etc/mahara/config.php var/www/mahara/config.php
etc/mahara/apache.conf etc/apache/conf.d/mahara
......@@ -21,8 +21,8 @@ set -e
. /usr/share/debconf/confmodule
TMP_M4_FILE=`mktemp`
APACHE_CONF_FILE=/etc/apache/conf.d/100-mahara
SERVERREDIRECTS_CONF_FILE=/etc/mahara/serverredirects.conf
SERVERNAME_CONF_FILE=/etc/mahara/servername.conf
case "$1" in
configure)
......@@ -55,21 +55,19 @@ case "$1" in
chown www-data:www-data /var/log/mahara-cron.log
# Configure apache
echo "changecom" > $TMP_M4_FILE
db_get mahara/servername
echo "define(__SERVERNAME__,${RET})dnl" >> $TMP_M4_FILE
echo "define(__APACHELOGDIR__,/var/log/apache)dnl" >> $TMP_M4_FILE
m4 $TMP_M4_FILE /usr/share/mahara/apache.conf.template > $APACHE_CONF_FILE
rm -f $TMP_M4_FILE
perl -i -p -e "s/^ServerName.*$/ServerName ${RET}/" $SERVERNAME_CONF_FILE
db_get mahara/serverredirects
if [ -n "${RET}" ]; then
echo '<VirtualHost *>' >> $APACHE_CONF_FILE
echo ${RET} | perl -ne '@s = split /\s*,\s*/; print " ServerName ", shift @s, "\n" if @s; print map { " ServerAlias $_\n" } @s;' >> $APACHE_CONF_FILE
echo '<VirtualHost *>' >> $SERVERREDIRECTS_CONF_FILE
echo ${RET} | perl -ne '@s = split /\s*,\s*/; print " ServerName ", shift @s, "\n" if @s; print map { " ServerAlias $_\n" } @s;' >> $SERVERREDIRECTS_CONF_FILE
db_get mahara/servername
echo " Redirect Permanent / http://${RET}/" >> $APACHE_CONF_FILE
echo '</VirtualHost>' >> $APACHE_CONF_FILE
echo " Redirect Permanent / http://${RET}/" >> $SERVERREDIRECTS_CONF_FILE
echo '</VirtualHost>' >> $SERVERREDIRECTS_CONF_FILE
else
echo '# DO NOT EDIT THIS FILE. It is managed by debconf!' > $SERVERREDIRECTS_CONF_FILE
fi
......
links
\ No newline at end of file
var/www/mahara/js/MochiKit/Packed.js var/www/mahara/js/MochiKit/setup.js
etc/mahara/config.debconf.php var/www/mahara/config.debconf.php
etc/mahara/config.php var/www/mahara/config.php
etc/mahara/apache.conf etc/apache2/conf.d/mahara
......@@ -21,8 +21,8 @@ set -e
. /usr/share/debconf/confmodule
TMP_M4_FILE=`mktemp`
APACHE_CONF_FILE=/etc/apache2/sites-available/mahara
SERVERREDIRECTS_CONF_FILE=/etc/mahara/serverredirects.conf
SERVERNAME_CONF_FILE=/etc/mahara/servername.conf
case "$1" in
configure)
......@@ -55,22 +55,19 @@ case "$1" in
chown www-data:www-data /var/log/mahara-cron.log
# Configure apache2
echo "changecom" > $TMP_M4_FILE
db_get mahara/servername
echo "define(__SERVERNAME__,${RET})dnl" >> $TMP_M4_FILE
echo "define(__APACHELOGDIR__,/var/log/apache2)dnl" >> $TMP_M4_FILE
m4 $TMP_M4_FILE /usr/share/mahara/apache.conf.template > $APACHE_CONF_FILE
ln -f -s /etc/apache2/sites-available/mahara /etc/apache2/sites-enabled/100-mahara
rm -f $TMP_M4_FILE
perl -i -p -e "s/^ServerName.*$/ServerName ${RET}/" $SERVERNAME_CONF_FILE
db_get mahara/serverredirects
if [ -n "${RET}" ]; then
echo '<VirtualHost *>' >> $APACHE_CONF_FILE
echo ${RET} | perl -ne '@s = split /\s*,\s*/; print " ServerName ", shift @s, "\n" if @s; print map { " ServerAlias $_\n" } @s;' >> $APACHE_CONF_FILE
echo '<VirtualHost *>' > $SERVERREDIRECTS_CONF_FILE
echo ${RET} | perl -ne '@s = split /\s*,\s*/; print " ServerName ", shift @s, "\n" if @s; print map { " ServerAlias $_\n" } @s;' >>$SERVERREDIRECTS_CONF_FILE
db_get mahara/servername
echo " Redirect Permanent / http://${RET}/" >> $APACHE_CONF_FILE
echo '</VirtualHost>' >> $APACHE_CONF_FILE
echo " Redirect Permanent / http://${RET}/" >> $SERVERREDIRECTS_CONF_FILE
echo '</VirtualHost>' >> $SERVERREDIRECTS_CONF_FILE
else
echo '# DO NOT EDIT THIS FILE. It is managed by debconf!' > $SERVERREDIRECTS_CONF_FILE
fi
restart_apache2;
......
......@@ -18,8 +18,15 @@ install: configure-stamp
dh_testroot
dh_installdirs
cp $(CURDIR)/debian/config.php $(CURDIR)/debian/mahara-apache2/etc/mahara/
# Config files (-apache)
cp $(CURDIR)/debian/config.php $(CURDIR)/debian/mahara-apache/etc/mahara/
cp $(CURDIR)/debian/apache.conf.template $(CURDIR)/debian/mahara-apache/etc/mahara/apache.conf
perl -i -p -e "s|__APACHELOGDIR__|/var/log/apache|" $(CURDIR)/debian/mahara-apache/etc/mahara/apache.conf
# Config files (-apache2)
cp $(CURDIR)/debian/config.php $(CURDIR)/debian/mahara-apache2/etc/mahara/
cp $(CURDIR)/debian/apache.conf.template $(CURDIR)/debian/mahara-apache2/etc/mahara/apache.conf
perl -i -p -e "s|__APACHELOGDIR__|/var/log/apache2|" $(CURDIR)/debian/mahara-apache2/etc/mahara/apache.conf
clean:
dh_testdir
......
# DO NOT EDIT THIS FILE! It is managed by debconf.
# It will be overwritten the next time this package is configured.
# Use 'dpkg-reconfigure' instead
ServerName __SERVERNAME__
# DO NOT EDIT THIS FILE. It is managed by debconf!
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment