#!/bin/bash
#
# starts Armagetron from the installation directory

INSTALL=/usr/lib64/games/armagetron

if test ! -r $HOME/.armagetron ; then
   mkdir $HOME/.armagetron

   if test -r $HOME/.ArmageTronrc ; then
       #migrage very old configuration
       echo "Porting very old configuration..."
       mkdir $HOME/.armagetron/var
       mv $HOME/.ArmageTronrc $HOME/.armagetron/var/user.cfg
   fi
fi

if test ! -r $HOME/.armagetron/var ; then
    #migrate old configuration
    files=$( find $HOME/.armagetron -type f -maxdepth 1 )

    mkdir $HOME/.armagetron/var
       
    test "$files" != "" && echo "Porting old configuration..." && mv $files $HOME/.armagetron/var
fi

if test  "x$1" = "x-h" ; then
    echo -e "\n\nTo uninstall Armagetron, type armagetron --uninstall."
fi

if test  "x$1" = "x--uninstall"  ; then
    $INSTALL/bin/uninstall
else
    $INSTALL/bin/armagetron --datadir $INSTALL --configdir /etc/armagetron --userdatadir $HOME/.armagetron $*
fi

