#!/bin/ash
#
#
#
 if [ ! -e /usr/games/quake/id1/pak0.pak ]; then
   echo "You need the game pak file to play Quake."
   read -p "Do you wish to download it now (y/n)?: " ANSWER
   ANSWER=y$ANSWER
   if [ $ANSWER = yy ]; then
     URL=http://www.libsdl.org/projects/quake/data/
     FILE=quakesw-1.0.6.tar.gz
     rm /tmp/$FILE 2>/dev/null
     echo "Downloading:"
     wget $URL$FILE -P /tmp
     if [ ! -e /tmp/$FILE ]; then
       URL=http://dl.4mlinux.com/
       wget $URL$FILE -P /tmp
     fi
     if [ ! -e /tmp/$FILE ]; then
       echo "Error in downloading. Check your internet connection."
       if [ ! x$DISPLAY = x ]; then
         read
       fi
       exit
       else
       tar -vxz -f /tmp/$FILE -C /usr/games/quake
       rm /tmp/$FILE
       if [ x$DISPLAY = x ]; then
         quake
       fi
     fi
   fi
   else
   cd /usr/games/quake
   if [ x$(cat /boot/boot.log | grep VirtualBox) = x ]; then
    ./sdlquake -fullscreen
    else
    ./sdlquake -fullscreen -nosound
   fi
 fi
