Commit 78a34770 authored by Melissa Draper's avatar Melissa Draper

* Add apache config

* Make code/log locations more configurable
parent 30682c1e
......@@ -4,9 +4,9 @@ set -e
PACKAGE=`basename $0 .postinst`
db_get maharadocs/installdir
cd /var/www/$RET
cd $RET
git pull
make -C /var/www/$RET update html epub latexpdf MAHARA=1.4
make -C /var/www/$RET update html epub latexpdf MAHARA=1.5
make -C /var/www/$RET update html epub latexpdf MAHARA=1.6
make -C /var/www/$RET update html epub latexpdf MAHARA=1.7
make -C $RET update html epub latexpdf MAHARA=1.4
make -C $RET update html epub latexpdf MAHARA=1.5
make -C $RET update html epub latexpdf MAHARA=1.6
make -C $RET update html epub latexpdf MAHARA=1.7
......@@ -12,6 +12,8 @@ case "$1" in
DIRNAME=$RET
db_get maharadocs/giturl
GITURL=$RET
db_get maharadocs/logdir
OVERWRITEDIR=$RET
db_get maharadocs/overwrite
OVERWRITEDIR=$RET
;;
......@@ -25,26 +27,26 @@ esac
# Check if we seem to have the correct git contents, not very trustworthy
# but better than no check :D
if [ -d /var/www/$DIRNAME ]
if [ -d $DIRNAME ]
then
if grep -Fxq $GITURL /var/www/$DIRNAME/.git/config
if grep -Fxq $GITURL $DIRNAME/.git/config
then
# If we have what appears to be the correct git contents,
# just quit the script cleanly and let the rest of the
# packaging do its thing.
echo "Data already exists pulling from the correct source."
echo "Not doing any alteration of /var/www/$DIRNAME."
echo "Not doing any alteration of $DIRNAME."
exit
else
# However if it looks wrong, check if its a-ok to overwrite
if [ "$OVERWRITEDIR" == "ok" ]
then
# Buhbye!
rm -rf /var/www/$DIRNAME
rm -rf $DIRNAME
else
# Throw an error stating that we don't feel right about
# nuking the data we can see.
echo "${bold}The directory '/var/www/$DIRNAME' already exists."
echo "${bold}The directory '$DIRNAME' already exists."
echo "We were not told to overwrite, so we will not."
echo "Exiting now. Retry with the overwrite option.${normal}"
exit
......@@ -55,17 +57,16 @@ fi
# Make our lovely new install from the git address.
# Despite all our checking, this can fail horribly after a long wait;
# there's not really much we can do about that now.
cd /var/www/
echo "Downloading the manual into /var/www/$DIRNAME from gitorious.org:"
echo "Downloading the manual into $DIRNAME from gitorious.org:"
echo "$GITURL"
echo "This may take a while..."
git clone $GITURL $DIRNAME
# Did we succeed?
if [ -d /var/www/$DIRNAME ]
if [ -d $DIRNAME ]
then
# Yay!
echo "Manual successfully downloaded into '/var/www/$DIRNAME'."
echo "Manual successfully downloaded into '$DIRNAME'."
else
# In theory, we should not be here. Throw an error if we did, guessing what might
# have happened. Git _should_ have reported all failures to download, but if the
......@@ -78,3 +79,83 @@ else
echo "the text output since you tried to install this. "
exit -1
fi
# Make the sitelogs directory...
mkdir -p /var/log/sitelogs/mahara-manual-sphinx
echo "${bold}Setting up Apache configuration...${normal}"
cat > /etc/apache2/sites-available/mahara-manual-sphinx.conf << EOF
<VirtualHost *:80>
ServerAdmin moodlehost@catalyst.net.nz
ServerName manual.mahara.org
DocumentRoot ${DIRNAME}/build/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory ${DIRNAME}/build/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${LOGDIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${LOGDIR}/access.log combined
# Convert wild existing links from before we vacated readthedocs.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)/1.4_STABLE/(.*)$ $1/1.4/$2
RewriteRule ^(.*)/1.5_STABLE/(.*)$ $1/1.5/$2
RewriteRule ^/$ /en/1.6/ [R]
</IfModule>
</VirtualHost>
EOF
# Enable the site
a2ensite mahara-manual-sphinx.conf
# Restart apache
# Nicked from http://www.ilestis.ch/2011/03/03/apache-auto-restart-if-config-check/
# Check current apachectl status
# - configtest sends to str.err, so map it back to str.out
CHECKCONF=`/usr/sbin/apachectl -t 2>&1`
# httpd service
HTTPDS='httpd'
# Is Syntax OK: restart
echo "Check syntax files..."
if [ "$CHECKCONF" = "Syntax OK" ]
then
echo "- Config seems OK."
echo "Restarting apache..."
RESTARTCTL=`/usr/sbin/apachectl restart 2>&1 | grep -v "httpd not running, trying to start"`
# If restart isn't empty, an error occured
if [ "$RESTARTCTL" != "" ]
then
echo "Error on restart: $RESTARTCTL"
echo ""
fi
# Check if apache is running successfully
echo "Check if httpd is running...."
if ps ax | grep -v grep | grep $HTTPDS > /dev/null
then
echo "- HTTPD is running"
else
echo "- Error: HTTPD isn't running!"
fi
else
echo "Configcheck error: $CHECKCONF"
echo ""
fi
......@@ -27,7 +27,9 @@ case "$1" in
purge|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
db_get maharadocs/installdir
DIRNAME=$RET
rm -rf /var/www/$DIRNAME
if [$DIRNAME !eq '/'];
rm -rf $DIRNAME
fi
;;
*)
......
Template: maharadocs/installdir
Type: string
Default: maharadocs
Default: /var/lib/sitedata/mahara-manual-sphinx
Description: Installation directory:
What directory should the mahara documentation be
What directory should the mahara manual sphinx site be
put in? This directory should not exist when installing
for the first time.
Template: maharadocs/logdir
Type: string
Default: /var/log/sitelogs/mahara-manual-sphinx
Description: Installation directory:
What directory should the apache sitelogs for the manual be
put in? This directory should not exist when installing
for the first time.
......
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