#!/bin/sh
# Install MediaWiki on the SQLite backend
# and then verify the installation was successful.
# We use /etc instead of /tmp for the data directory
# since apache has a private tmp directory.
set -e

sudo mkdir /etc/mw-install
sudo chgrp www-data /etc/mw-install
sudo chmod g+w /etc/mw-install
sudo -u www-data php /var/lib/mediawiki/maintenance/install.php --confpath /etc/mw-install --dbpath /etc/mw-install --dbtype sqlite --pass password1 Debian-Autopkgtest Administrator
sudo echo '$wgShowExceptionDetails = true; $wgShowDBErrorBacktrace = true;' >> /etc/mw-install/LocalSettings.php
sudo -u www-data php /var/lib/mediawiki/maintenance/getText.php --conf /etc/mw-install/LocalSettings.php "Main_Page" | grep "MediaWiki has been installed"
sudo -u www-data php /var/lib/mediawiki/maintenance/update.php --conf /etc/mw-install/LocalSettings.php --quick
sudo cp /etc/mw-install/LocalSettings.php /etc/mediawiki/LocalSettings.php
curl --silent -I "http://localhost/mediawiki/index.php/Main_Page"
curl --silent "http://localhost/mediawiki/index.php/Main_Page" | grep "MediaWiki has been installed"
curl --silent "http://localhost/mediawiki/index.php/Special:BlankPage" | grep "This page is intentionally left blank."
