#!/bin/sh

# Unreal installer for Linux (4 January 2000)
#
# Method: Doug Dahl (dougdahl@incentre.net)
#         John Matthews (jvm@linuxgames.com)
# Script: John Matthews (jvm@linuxgames.com)
# Contact: John Matthews (jvm@linuxgames.com)
#
# Quick directions:
# 1) Install and patch Unreal Tournament.  Make sure it works!
# 2) Configure this script.
# 3) Mount Unreal CD-ROM
# 4) Change to root and run the script.
# 5) Backup *.ini files in UT System directory.
# 6) Make changes to *.ini files as described below.
# 7) Run UnrealTournament.
# 8) Enjoy Unreal startup demo.  To play, bring down console, type 
#    "open vortex2".
#
# This script will assist you in installing Unreal on your system so that
# you can play it with Unreal Tournament.  It is designed to be run as root
# (since otherwise you can't change the ownership and permissions on the
# files/directories), and as with all such scripts, make sure you know what
# you're doing before you use it.  Take a second to configure it for your
# system (the definitions below for unrealdir, utdir, etc) and then read over
# the rest of the script and see what it does.  This is what _I_ use, so
# it will by no means fit your setup perfectly.
#
# Assuming you've run the script succesfully, you'll then need to change
# some items in your UnrealTournament/System/*.ini files.  These are outlined
# below.  Make backups of those files first!  Once those changes are made, you
# can now go to UnrealTournament/System and start up UT (running Unreal) with
# ./UnrealTournament
# (It's probably possible to make this work by copying your UT System directory
# to the Unreal directory, but I had problems with that.  I'll put up a revised
# script if/when I know how to do it properly.)
# 
# With any luck you will have the Unreal demo running (sans the great music) 
# in its full glory.  Then hitting ESC will bring up the UT GUI (but with
# Unreal options) and you can twiddle around with the items in there.  I've
# had mixed luck playing with those options, so be careful; this is still
# far from stable!  To actually start a game, bring down the console (default
# keystroke for that is the ` (what I call the backquote) key) and type "open
# vortex2".  This will start the single player game.  (Hit the same key to
# remove the console.)  To read the translator messages, hit the F2 key
# (this is the change in the User.ini file made below).  Further, note that
# some maps _do not_ work.  Among the ones known not to work are: Dug, NaliC, 
# Ruins, Dark, and TheSunSpire.  (However, these crash for different reasons.
# On my system, some give a signal error along with a seg fault and the others
# just give a seg fault.)  Finally, saving games (and consequently loading
# saved games) doesn't seem to work.
#
# IMPORTANT:  Back up your UnrealTournament.ini and User.ini files FIRST!
#
# Once you've made backups of those files, you can modify them safely...
#
# In $utdir/System/UnrealTournament.ini make the following changes.
# (Not _deletions_...just _changes_!  Be sure to take into account your own 
# system config.  It's pretty easy to see what's being changed here...)
#
# [URL]
# LocalMap=Unreal.unr 
#
# [Core.System]
# SavePath=/usr/local/games/Unreal/Save
# CachePath=/usr/local/games/Unreal/Cache
# Changeths=/usr/local/games/Unreal/Maps/*.unr
# Paths=/usr/local/games/Unreal/Textures/*.utx
# Paths=/usr/local/games/Unreal/Sounds/*.uax
# Paths=/usr/local/games/Unreal/Music/*.umx
#
# [Engine.Engine]
# DefaultGame=UnrealI.SinglePlayer
#
# In $utdir/System/User.ini make the following changes.
#
# F2=ActivateTranslator


# IMPORTANT: Configure these to fit your system.
#
# Target Unreal directory
unrealdir=/usr/local/games/Unreal
# Installed UT directory
utdir=/usr/local/games/UnrealTournament
# Location of Unreal CD-ROM
cdrom=/mnt/cdrom
# Owner
owner=root
# Group
group=games

if [ -e $cdrom/Maps ]
  then
  mkdir $unrealdir
  cp -a $cdrom/Maps $cdrom/Sounds $cdrom/Textures $cdrom/Music $unrealdir
  chown -R root.games $unrealdir
  chmod -R ug+rwx $unrealdir
  chmod -R o-rwx $unrealdir
  for file in `ls $utdir/Textures`
    do
      if [ ! -e $unrealdir/Textures/$file ]
        then ln -s $utdir/Textures/$file $unrealdir/Textures/$file
      fi
    done
  for file in `ls $utdir/Sounds`
    do
      if [ ! -e $unrealdir/Sounds/$file ]
        then ln -s $utdir/Sounds/$file $unrealdir/Sounds/$file
      fi
    done
  # Just to be sure
  chown -R root.games $unrealdir
  chmod -R ug+rwx $unrealdir
  chmod -R o-rwx $unrealdir
else
  echo "Please put the Unreal CD-ROM in $cdrom."
  exit
fi
exit
