#!/bin/sh
# postinst script for fookebox

set -e

case "$1" in
	configure)
		# only on new installations
		if [ "$2" = "" ] ; then
			# Create database
			python /usr/share/fookebox/create-database.py
			chgrp www-data /var/lib/fookebox/fookebox.sqlite
			chmod 0660 /var/lib/fookebox/fookebox.sqlite

			# Set permissions
			chgrp -R www-data /var/cache/fookebox
			chgrp www-data /var/lib/fookebox
			chgrp www-data /etc/fookebox/apache.conf
			chgrp www-data /etc/fookebox/fookebox.wsgi
			chgrp www-data /etc/fookebox/config.ini
		fi
	;;

	abort-upgrade|abort-remove|abort-deconfigure)
	;;

	*)
		echo "postinst called with unknown argument \`$1'" >&2
		exit 1
	;;
esac

#DEBHELPER#

exit 0
