#!/bin/bash

# Simple Installer for RoboTour

# HELP function
function showhelp {
  echo "Simple installer for RoboTour (c) 2000-2004 by Florian Fischer"
  echo "and Martin Trautmann."
  echo "Usage: $0 [version]    (run as root)"
  echo "   where version specifies which RoboTour version should"
  echo "   be installed. It may be one of"
  echo "     (nothing) for autodetection (recommended)"
  echo "     gl        for forcing the OpenGL version"
  echo "     wx        for forcing the GUI version"
  echo "     cmd       for forcing the command-line version"
  echo
}


# Check CMDLine Argument
# sets the rtprog variable to (either) a robotour executable name
# or the special value all.

case $1 in
  2d | x | 2D | X | wx | WX | normal | NORMAL ) rtprog=robotour;;
  3d | gl | 3D | GL ) rtprog=glrobotour;;
  cmd | CMD | cmdline | CMDLINE ) rtprog=cmdrobotour;;
  all | ALL ) rtprog=all;;
  "" ) echo Auto-detection, please wait... ;
    if ./glrobotour -help >/dev/null; then rtprog=glrobotour;
    elif ./robotour -help >/dev/null; then rtprog=robotour;
    elif ./cmdrobotour -help >/dev/null; then rtprog=cmdrobotour;
    else echo Error. Cannot start any RoboTour version. Installation aborted.; exit;
    fi;;
  * ) showhelp; exit;;
esac


# Confirm installation

echo "Really install RoboTour? (Press ENTER or enter Y to confirm)";
read CONFIRM
if [ "$CONFIRM" != "y" -a "$CONFIRM" != "Y" -a "$CONFIRM" != "" ]; then
  echo "Installation aborted.";
  exit;
fi


# Install RoboTour
echo "Installing RoboTour ($rtprog)..."

if [ $rtprog = "all" ]; then
  cp -p *robotour /usr/bin;
else
  cp -p $rtprog /usr/bin/robotour;
fi;


# Install other programs
echo Installing auxiliary programs...

cp -ip kickbot makehtml /usr/bin


# Install data
echo Installing sounds, samples, help, and option sets...

mkdir /usr/share/robotour
cp -rp samples/ sounds/ help/ optsets/ /usr/share/robotour


# Done.
echo Installation finished. Have fun with RoboTour!
echo


