#!/bin/sh -e

REALTRON=/usr/games/armagetron.real

DATADIR=/usr/share/games/armagetron
CONFDIR=/etc/armagetron
USERCONFDIR=$HOME/.armagetron
USERDATADIR=$USERCONFDIR/data
VARDIR=/var/lib/games/armagetron
if [ ! -d $USERCONFDIR ]; then
	# have to create configuration directory
	install -d $USERCONFDIR
fi
if [ -f $HOME/.armagetronrc ]; then
	# upgrade from before 0.2
	mv -f $HOME/.armagetronrc $USERCONFDIR/user.cfg
fi

CMDLINE="--datadir $DATADIR --configdir $CONFDIR --userconfigdir $USERCONFDIR --vardir $VARDIR"
if [ -d $USERDATADIR ]; then
	CMDLINE="$CMDLINE --userdatadir $USERDATADIR"
fi
exec $REALTRON $CMDLINE "$@"
