#!/bin/sh

dbadapter="${1:-sqlite3}"
setup="${2:-apache2-passenger-host}"
uri="${3:-/}"

exec 2>&1
set -eux

grep "adapter:[[:space:]]*$dbadapter" /etc/redmine/default/database.yml

a2enmod rewrite

sed -e '/<VirtualHost/ a ServerName localhost' /usr/share/doc/redmine/examples/${setup}.conf > /etc/apache2/sites-enabled/redmine.conf

service apache2 restart

curl -s http://localhost${uri} | grep 'meta.*name="description".*content="Redmine"'
curl -s http://localhost${uri}/login | grep 'meta.*name="description".*content="Redmine"'
