#!/bin/sh
#
# Doom wrapper script. By Joey Hess <joeyh@master.debian.org>, GPL copyright.

if [ ! -d ~/.doom ]; then
	mkdir ~/.doom
fi

# Remove all old symlinks for .wad files in ~/.doom/ directory.
cd ~/.doom
find -type l -name \*.wad |xargs rm -f

# Make new symlinks for all .wad files from DOOMWADDIR.
cd $DOOMWADDIR
files=`find -name \*.wad -maxdepth 1`
if [ "$files" ]; then
        for file in $files ; do
                ln -s "$DOOMWADDIR/$file" ~/.doom/$file
        done
fi

unset DOOMWADDIR
cd ~/.doom
exec /usr/lib/games/doom/linuxxdoom $@
