Someone was asking me about this, so I'll send it to the whole list as a FYI.



This is all in bash.

To create the directories and file links, I use a tool called lns, which you can get here;
http://www.chiark.greenend.org.uk/~sgtatham/utils/

I also use a tool called symlinks, which is in Debian and Debian derivatives as the "symlinks" package.

We assume here that both tf2-custom and tf2-master are directories found within $APPDIR.

In this case, you would run your HLDSUpdateTool/SteamCMD against the master server and never the linked installation. After each update, you would need to re-link, to add new link files and remove old ones.



APPDIR=/srv/srcds-servers
INSTALLID=tf2-custom
MASTER=tf2-master

echo "Relinking $INSTALLID to master $MASTER ..."
lns -q -r "$APPDIR/$MASTER/"* "$APPDIR/$INSTALLID"

echo "Looking for old dangling symlinks and remove them..."
symlinks -d -r "$APPDIR/$INSTALLID"



To de-link an installation, you would do this:

# Find and remove the symlinks related to the master installation.
find "$APPDIR/$INSTALLID" -type l -lname "*../$MASTER/*" -exec rm -f '{}' +

# Also delete directories which have no files anywhere within them.
find "$APPDIR/$INSTALLID" -type d -empty -delete



What if you already have an installation and need to de-duplicate it so that you can link it?

This will find all files in the SRCDIR and if there is an identically named/pathed file with the same md5sum in the DSTDIR, it will delete it. It won't touch custom files.

SRCDIR=$APPDIR/$MASTER
DSTDIR=$APPDIR/$INSTALLID

cd "$SRCDIR"
find . -type f -printf "%P\0" | while read -d $'\0' EACH ; do
  SRCFILE="$SRCDIR/$EACH"
  DSTFILE="$DSTDIR/$EACH"
  if [[ -r "$SRCFILE" ]] && [[ -r "$DSTFILE" ]] ; then
    SRCHASH=$(md5sum "$SRCFILE" | awk '{print $1}')
    DSTHASH=$(md5sum "$DSTFILE" | awk '{print $1}')
  else
    echo "Skipping file: $EACH"
    continue
  fi
  if [[ "$SRCHASH" == "$DSTHASH" ]] ; then
    echo "Removing duplicate file in destination: $EACH"
    rm -f "$DSTFILE"
  else
    echo "Non-duplicate file found: $EACH"
  fi
done

Then do "find "$DSTDIR" -type d -empty -delete" to delete the empty directories left over.

This will take a long time for TF2, which has something like 60,000 files.





--
# Jesse Molina
# Mail = [email protected]
# Cell = 1-602-323-7608



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux

Reply via email to