#!/bin/sh
# postinst script for gweled
#

set -e

case "$1" in
    configure)
	if [ -f /var/games/gweled.easy.scores ]; then
	    if [ ! -f /var/games/gweled.Normal.scores ]; then
		mv /var/games/gweled.easy.scores /var/games/gweled.Normal.scores;
	    else
		rm /var/games/gweled.easy.scores;
	    fi
	fi
	if [ -f /var/games/gweled.timed.scores ]; then
	    if [ ! -f /var/games/gweled.Timed.scores ]; then
		mv /var/games/gweled.timed.scores /var/games/gweled.Timed.scores;
	    else
		rm /var/games/gweled.timed.scores;
	    fi
	fi

	if [ -f /var/games/gweled.hard.scores ]; then
	    rm /var/games/gweled.hard.scores;
	fi

	for scorefile in Normal Timed; do
	    [ ! -f /var/games/gweled.${scorefile}.scores ] && \
		touch /var/games/gweled.${scorefile}.scores;
	    chown root:games /var/games/gweled.${scorefile}.scores;
	    chmod 664 /var/games/gweled.${scorefile}.scores;
	done

	# The package used to install an override
	if [ "$(sudo dpkg-statoverride --list /usr/games/gweled)" = "root games 2755 /usr/games/gweled" ]; then
	    dpkg-statoverride --remove /usr/games/gweled
	fi
    ;;

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

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

#DEBHELPER#

exit 0
