EDIT: here's the first bugfix... I forgot copying to System folder. I also left the Animations folder apart. Changes are commented. Note: the script supports French (frt) and international (int) files. Update to the appropriate language if required.
I don't think this has been published in the forums hence my post. I've been very lazy copying maps, models, skins (aso) I found in files I downloaded for my games.
There are lots of sites where you can download new maps, models and skins for UT2K3/UT2K4. I've downloaded some but I went quite lazy: extract, chmod, chown, copy preserving attributes... I wanted to ease copying these files to an existing installation of Unreal Tournament 2003/2004 without breaking/messing up security, mostly.
I've written my very first bash script to do the following:
- extract files from a Zipped archive into a temporary folder
- apply the same security on files as in UT (owner and mode)
- move extracted files to the game folder
- remove the temporary folder.
Optionnally I also wanted to be able to select either UT2003 or UT2004 with the script. I didn't care much of Unreal Tournament for I already have zillions (
Code: Select all
#!/bin/bash
# Unpack Unreal Tournament downloaded archives to a target directory
# Example: ./unpack -t ut2003 /download/dm-morta.zip
# Arguments:
# archive source archive
# -t ut2003|ut2004 copy files to either UT2003 or UT2004
# -m zip|bz2|tar method (default is ZIP)
E_BADDIRECTORY=-1
E_BADMODE=-2
E_ARGMISSING=-3
Mode=zip
Source=/
Target=/
until [ -z "$1" ]
do
case $1 in
"-t" )
Target=/opt/$2
shift;;
"-m" )
Mode=$2
shift;;
* ) Source=$1 ;;
esac
shift
done
# Check target game directory
if [ $Target != /opt/ut2003 -a $Target != /opt/ut2004 ]; then
echo "Error: target game must be either 'ut2003' or 'ut2004'" 1>&2
exit $E_BADDIRECTORY
fi
# Check packing mode
if [ $Mode != "zip" -a $Mode != "bz2" -a $Mode != "tar" ]; then
echo "Error: archive type must be either 'zip', 'bz2' or 'tar'." 1>&2
exit $E_BADMODE
fi
# debug: echo "Source archive: $Source, target directory: $Target, mode: $Mode"
# debug: exit 0
# Create a temporary directory and subfolders
# $1: path to temporary folder to create
function CreateTempDir() {
if [ -z $1 ]; then
echo "Error: CreateTempDir requires target directory." 1>&2
exit $E_ARGMISSING
fi
mkdir $1
mkdir $1/System
# BUGFIX (Oct. 18, 2004): Create folder Animations
mkdir $1/Animations
# BUGFIX
mkdir $1/Maps
mkdir $1/Textures
mkdir $1/KarmaData
mkdir $1/Music
mkdir $1/Sounds
mkdir $1/StaticMeshes
}
# Unzip files
# $1: source archive
# $2: temporary directory for extract
function Unzip() {
if [ -z $1 ]; then
echo "Error: Unzip requires source and target directory." 1>&2
exit $E_ARGMISSING
fi
if [ -z $2 ]; then
echo "Error: Unzip also requires target directory." 1>&2
exit $E_ARGMISSING
fi
# BUGFIX (Oct. 18, 2004): Unzip to folder Animations; include *.ucl files in System
# Note: add/change frt to include other language files than (est, itt,...)
unzip -o -j $1 *.ukx -d $2/Maps 2>/dev/null
unzip -o -j $1 *.u *.ucl *.upl *.int *.frt -d $2/System 2>/dev/null
# BUGFIX
unzip -o -j $1 *.ut2 -d $2/Maps 2>/dev/null
unzip -o -j $1 *.utx -d $2/Textures 2>/dev/null
unzip -o -j $1 *.ka -d $2/KarmaData 2>/dev/null
unzip -o -j $1 *.ogg -d $2/Music 2>/dev/null
unzip -o -j $1 *.uax -d $2/Sounds 2>/dev/null
unzip -o -j $1 *.usx -d $2/StaticMeshes 2>/dev/null
}
# Set permissions
# $1: temporary directory where files were extracted
function SetPermissions() {
if [ -z $1 ]; then
echo "Error: SetPermissions requires target directory." 1>&2
exit $E_ARGMISSING
fi
chown -R root:games $1 2> /dev/null
chmod -R 640 $1/* 2> /dev/null
chmod ug+x $1/Music/* 2> /dev/null
}
# Copy files to the final destination, ut2003 or ut2004
# Update only, don't overwrite
# $1: temporary directory where files were extracted
# $2: destination game folder (full path)
function CopyFiles() {
if [ -z $1 ]; then
echo "Error: CopyFiles requires source and target directory." 1>&2
exit $E_ARGMISSING
fi
if [ -z $2 ]; then
echo "Error: CopyFiles also requires target directory." 1>&2
exit $E_ARGMISSING
fi
cp -pu $1/Maps/* $2/Maps 2>/dev/null
cp -pu $1/Textures/* $2/Textures 2>/dev/null
cp -pu $1/KarmaData/* $2/KarmaData 2>/dev/null
cp -pu $1/Music/* $2/Music 2>/dev/null
cp -pu $1/Sounds/* $2/Sounds 2>/dev/null
cp -pu $1/StaticMeshes/* $2/StaticMeshes 2>/dev/null
# BUGFIX (Oct. 18, 2004): Copy folders System and Animations
cp -pu $1/Animations/* $2/Animations 2>/dev/null
cp -pu $1/System/* $2/System 2>/dev/null
# BUGFIX
}
# Create a temporary directory; pattern /tmp/utmpNNNNN
# where NNNNN is a positive integer:
Number=$RANDOM
TempDir=/tmp/utmp$Number
echo "Creating temp: $TempDir..."
CreateTempDir $TempDir
# Extract files then set permissions
case $Mode in
"zip" ) Unzip $Source $TempDir;;
"*" ) echo "Warning: archive mode $Mode not supported yet.";;
esac
SetPermissions $TempDir
CopyFiles $TempDir $Target
# Remove temporary directory
# debug: ls -lR $TempDir
echo "Removing temporary files..."
rm -r $TempDir
echo "Done."The script works well on Gentoo provided the games are installed in their expected directory, i.e. /opt/ut200?. To use the script, I have created a common directory, e.g. /download, where everybody can write. Little plus: I also modified /etc/skel to contain a symlink to the common download folder, so that every new user can access it from his/her home directory. But it's not required.
Then I run a command shell, su to root and run the script against the archives I just downloaded. The script "recognizes" files in an archive: textures, maps, karma data, sounds, music, meshes and system files. It leaves readmes apart and other text files or screenshots.
It does not change UT200x.ini nor adds the required lines about new characters (serverpackages and player information). It must be done manually. The script could be modified to show the readme (if any) after extract is done... Finally you need unzip on your system for the script to run properly.
Hope this helps.

