#!/bin/sh
set -e

#create maelstrom high-score directory
SCOREDIR=/var/games
if [ ! -e ${SCOREDIR} ] ; then
    install -d ${SCOREDIR}
    chown root:games ${SCOREDIR}
    chmod 2775 ${SCOREDIR}
fi

#remove old symlink which may point to the wrong file
if [ -e /usr/lib/games/maelstrom/Maelstrom-Scores ] ; then
	rm -f /usr/lib/games/maelstrom/Maelstrom-Scores
fi

ln -sf ${SCOREDIR}/Maelstrom-Scores /usr/lib/games/maelstrom/Maelstrom-Scores

#install the default score file
if [ ! -e ${SCOREDIR}/Maelstrom-Scores ] ; then
	echo "installing debian default score file..."
	install -p -m 664 -g games \
       /usr/lib/games/maelstrom/Maelstrom-Scores.debian \
       ${SCOREDIR}/Maelstrom-Scores
fi

#DEBHELPER#
