#!/bin/sh
#
# U2UT
# Matt Matthews (jvmatthe@eos.ncsu.edu)
#
# edited 03 Aug 2000 Andy Piper
# updated details for Loki's UT release (version 425)
#
# Script (i.e. "hack") to link Unreal deathmatch maps from the Unreal CD-ROM 
# to the Unreal Tournament Maps directory.  To configure for your system, 
# edit the variables below.  Then execute this script as root.  (Note:
# You should be wary of things that one runs as root.  Check over this script
# to make sure you know what it does!)
#
# I decided to use this as my first lesson in script writing so no comments
# on how well it's written.  It gets the job done.
# 
# Note:
# Use at your own risk!  If this script uninstalls Linux, installs 
# Windows2000 in its place, and deletes all your pr0n, it's not my problem.
# I know it works for me, but that's all I can promise.  ;^)
#

# Change the value of cdrom to match the mount point for the Unreal CD-ROM
cdrom=/mnt/cdrom
# Change the value of utroot to match the location of UT on your system
utroot=/usr/local/games/ut
# Change the value of owner to match the userid of the owner of the links
owner=root
# Change the value of group to match the userid of the group for the links
group=games

# First, check to see if we can find $cdrom/Maps
if [ -d $cdrom/Maps ]
  then 
    echo "Found Unreal Maps directory: $cdrom/Maps"
else
  echo "Couldn't find Unreal Maps directory."
  echo "Edit this script and check definition of cdrom."
  echo "Alternatively, check to see if your Unreal CD-ROM is mounted."
  exit
fi

# Now does the user have UT on the system?
if [ -d $utroot ]
  then
# How about a Maps directory?
  if [ -d $utroot/Maps ]
    then
# We're all set to install.
      echo "Found UT installation Maps directory: $utroot/Maps"
      echo
      echo "  The following maps will be linked from $cdrom/Maps to"
      echo "  $utroot/Maps.  They will then be playable"
      echo "  from within the game, provided the Unreal CD-ROM is mounted."
      echo
      echo "  DmAriza.unr -> DM-Ariza.unr"
      echo "  DmCurse.unr -> DM-Curse.unr"
      echo "  DmDeathFan.unr -> DM-DeathFan.unr"
      echo "  DmDeck16.unr -> DM-Deck16.unr"
      echo "  DMElsinore.unr -> DM-Elsinore.unr"
      echo "  DMfith.unr -> DM-Fifth.unr"
      echo "  DmHealPod.unr -> DM-HealPod.unr"
      echo "  DmMorbias.unr -> DM-Morbias.unr"
      echo "  DmRadikus.unr -> DM-Radikus.unr"
      echo "  DmTundra.unr -> DM-Tundra.unr"
      echo
      echo "  Please press <Enter> to continue."
      read
      ln -sf $cdrom/Maps/DmAriza.unr $utroot/Maps/DM-Ariza.unr
      if [ -L $utroot/Maps/DM-Ariza.unr ]
        then echo " DmAriza.unr linked to DM-Ariza.unr"
        chown $owner.$group $utroot/Maps/DM-Ariza.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmCurse.unr $utroot/Maps/DM-Curse.unr
      if [ -L $utroot/Maps/DM-Curse.unr ]
        then echo " DmCurse.unr linked to DM-Curse.unr"
        chown $owner.$group $utroot/Maps/DM-Curse.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmDeathFan.unr $utroot/Maps/DM-DeathFan.unr
      if [ -L $utroot/Maps/DM-DeathFan.unr ]
        then echo " DmDeathFan.unr linked to DM-DeathFan.unr"
        chown $owner.$group $utroot/Maps/DM-DeathFan.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmDeck16.unr $utroot/Maps/DM-Deck16.unr
      if [ -L $utroot/Maps/DM-Deck16.unr ]
        then echo " DmDeck16.unr linked to DM-Deck16.unr"
        chown $owner.$group $utroot/Maps/DM-Deck16.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DMElsinore.unr $utroot/Maps/DM-Elsinore.unr
      if [ -L $utroot/Maps/DM-Elsinore.unr ]
        then echo " DMElsinore.unr linked to DM-Elsinore.unr"
        chown $owner.$group $utroot/Maps/DM-Elsinore.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DMfith.unr $utroot/Maps/DM-Fith.unr
      if [ -L $utroot/Maps/DM-Fith.unr ]
        then echo " DMfith.unr linked to DM-Fith.unr"
        chown $owner.$group $utroot/Maps/DM-Fith.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmHealPod.unr $utroot/Maps/DM-HealPod.unr
      if [ -L $utroot/Maps/DM-HealPod.unr ]
        then echo " DmHealPod.unr linked to DM-HealPod.unr"
        chown $owner.$group $utroot/Maps/DM-HealPod.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmMorbias.unr $utroot/Maps/DM-Morbias.unr
      if [ -L $utroot/Maps/DM-Morbias.unr ]
        then echo " DmMorbias.unr linked to DM-Morbias.unr"
        chown $owner.$group $utroot/Maps/DM-Morbias.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmRadikus.unr $utroot/Maps/DM-Radikus.unr
      if [ -L $utroot/Maps/DM-Radikus.unr ]
        then echo " DmRadikus.unr linked to DM-Radikus.unr"
        chown $owner.$group $utroot/Maps/DM-Radikus.unr 
      else
        echo "Link failed."
      fi
      ln -sf $cdrom/Maps/DmTundra.unr $utroot/Maps/DM-Tundra.unr
      if [ -L $utroot/Maps/DM-Tundra.unr ]
        then echo " DmTundra.unr linked to DM-Tundra.unr"
        chown $owner.$group $utroot/Maps/DM-Tundra.unr 
      else
        echo "Link failed."
      fi
		echo
		echo "Finished"
  else
    echo "Couldn't find UT installation directory."
    echo "Edit this script and check definition of utroot."
    exit
  fi
else
  echo "Couldn't find UT installation directory."
  echo "Edit this script and check definition of utroot."
  exit
fi

