#!/bin/sh
# $FreeBSD: head/www/ajaxplorer/files/pkg-install.in 322446 2013-07-07 15:48:16Z madpilot $

if [ "$2" != "POST-INSTALL" ]; then
	exit 0
fi

if [ -d /usr/local/www/ajaxplorer/data/cache -a -d /usr/local/www/ajaxplorer/data/cache/i18n ]; then
	show_warn=no
	wf=`( find /usr/local/www/ajaxplorer/data/cache/i18n -not -type d ; find /usr/local/www/ajaxplorer/data/cache -name 'plugins_*.ser' ) | wc -l`

	if [ $wf -ne 0 ]; then
		rm -f /usr/local/www/ajaxplorer/data/cache/i18n/*.ser
		rm -f /usr/local/www/ajaxplorer/data/cache/plugins_*.ser
		show_warn=yes
	fi

	if [ -f /usr/local/www/ajaxplorer/data/cache/admin_counted ]; then
		cp /usr/local/www/ajaxplorer/data/cache/admin_counted /usr/local/www/ajaxplorer/data/cache/first_run_passed
		show_warn=yes
	fi

	if [ "$show_warn" = "yes" ]; then
		echo "************************************************************************"
		echo
		echo "WARNING: If you are upgrading from version 4.2.3 and using a database"
		echo "backend, please update your database using the sql script installed in"
		echo "/usr/local/www/ajaxplorer/conf/4.2.3-5.0.0-db-upgrade.sql"
		echo
		echo "Please also read the upgrading notes at:"
		echo "http://ajaxplorer.info/ajaxplorer-5-0-0:/#Upgrade_from_4X_to_500"
		echo
		echo "************************************************************************"
		sleep 3
	fi
fi

exit 0
