#!/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

	dpkg-statoverride --remove /usr/games/gweled >/dev/null 2>&1 || true
	dpkg-statoverride --update --add root games 02755 /usr/games/gweled
    ;;

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

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

#DEBHELPER#

exit 0
