#!/bin/sh #include #v 0.8 # Edit the following target=.. line to change the targetdir, the # cachefiles will be moved into its subdirs # usually /usr/local/games/ut2004 or ~/.ut2004 - for the former read below! target=/usr/local/games/ut2004 # Script to move the *.uxx cache files from ~/.ut2004/Cache under # their real name to the corresponding ut2004 subdirs which are # Animations/ Maps/ Music/ Sounds/ StaticMeshes/ Textures/ # - This can be either the global installdir (/usr/local/games/ut2004 usually) # since it is usually owned by root you have to change the permissions a bit: # You can either do it the simple way, but then anyone will be able # to place files in the subdirs but not delete files added by others due to # the "sticky" bit (+t): # cd $target; chmod o+wt # Or add yourself to the group "games" (or similar) and then change the group # ownership of these subdirs to "games" and give the group write permissions, # setting the sticky bit will prevent overwriting files added by possible other # members of the games group or of the installation itself (since these are owned by # root): # cd $target; chgrp games ; chmod g+ws ; chmod +t # - Or just use the personal ~/.ut2004 dir for which most likely the first have to be # generated $ cd ~/.ut2004 && mkdir -p Animations/ Maps/ Music/ Sounds/ StaticMeshes/ Textures/ # and target= has to be changed above, these files will then only be available to you. # Note that modfiles (*.u) which would go to the System/ subdir # should better be installed manually, this script leaves them in the Cache. # GPL'ed :) - by hethrep at linux-gamers dot net # Dont edit below unless you know what you are doing cachedir=~/.ut2004/Cache #cmd="echo mv" # test, also comment out last line if testing! cmd="mv -v" # action, DON'T add '-i' since piping into sh # is strictly noninteractive cd "$cachedir" || { echo "Error: Couldn't cd into $cachedir"; exit 1; } echo '[Cache]' > cache.ini.new # keep a few backups, delete older ones rm -f `ls -t cache.ini.bak.* | tail +5` cp cache.ini cache.ini.bak.$$ grep '=' cache.ini | sed 's,\(`\|\$\),\\\1,g' | awk --field-separator '=' \ --assign cmd="$cmd" --assign=target="$target" \ '{ #print $1" "$2; # ya test here if(match($2,".ukx$")) { printf cmd" \""$1".uxx\" \""target"/Animations/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else if(match($2,".ut2$")) { printf cmd" \""$1".uxx\" \""target"/Maps/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else if(match($2,".ogg")) { printf cmd" \""$1".uxx\" \""target"/Music/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else if(match($2,".uax$")) { printf cmd" \""$1".uxx\" \""target"/Sounds/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else if(match($2,".usx$")) { printf cmd" \""$1".uxx\" \""target"/StaticMeshes/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } # preferably not... - better install mods youself # else if(match($2,".u$")) { printf cmd" \""$1".uxx\" \""target"/System/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else if(match($2,".utx$")) { printf cmd" \""$1".uxx\" \""target"/Textures/"$2"\" || echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } else printf "echo \""$1"="$2"\" >> cache.ini.new\n" | "sh"; } END { close("sh") }' #comment out if testing: mv cache.ini.new cache.ini