#!/bin/sh

a=install2-init-functions
. "$a"

# Fix path to School Portal in DocumentRoot
test -e $destdir/var/www/html/sp && run_chroot ln -s /var/www/html/sp /usr/share/doc/indexhtml/sp 2>/dev/null

# Update MediaWiki database
mw_update_script="/usr/share/mediawiki/maintenance/update.php"
test -e $destdir/$mw_update_script && run_chroot php "$mw_update_script" >/dev/null

# Remove trusted domains and leave maintenance mode for Owncloud
owncloud_config="/etc/owncloud/config.php"
if [ -e "$destdir/$owncloud_config" ] ; then
	sed -i "/'trusted_domains'/,/),/ d" "$destdir/$owncloud_config" >/dev/null
	sed -i "/'maintenance'/d;$ i \ \ 'maintenance' => false," "$destdir/$owncloud_config" >/dev/null
fi
