#!/bin/sh

echo Checking for required files
echo

if [ -d data ]
then
    echo PASSED: data directory exists
else
    echo FAILED: data directory missing
    exit
fi

if [ -d override ]
then
    echo PASSED: override directory exists
else
    echo FAILED: override directory missing
    exit
fi

if [ -f chitin.key ]
then
    echo PASSED: chitin.key exists
else
    echo FAILED: chitin.key missing
    exit
fi

if [ -f dialog.tlk ]
then
    echo PASSED: dialog.tlk exists
else
    echo FAILED: dialog.tlk missing
    exit
fi

if [ -f nwserver ]
then
    echo PASSED: nwserver exists
else
    echo FAILED: nwserver missing
    exit
fi

echo 
echo Checking for recommended files
echo

if [ -d nwm ]
then
    echo PASSED: nwm directory exists
else
    echo WARNING: nwm directory missing
fi

if [ -d modules ]
then
    echo PASSED: modules directory exists
else
    echo WARNING: modules directory missing
fi

if [ -d hak ]
then
    echo PASSED: hak directory exists
else
    echo WARNING: hak directory missing
fi

if [ -d patch ]
then
    echo PASSED: patch directory exists
else
    echo WARNING: patch directory missing
fi

if [ -f nwnplayer.ini ]
then
    echo PASSED: nwnplayer.ini exists
else
    echo WARNING: nwnplayer.ini missing
fi

echo
echo Fixing override
echo

cd override

for f in $(find *.*)
do
    lcf=$(echo $f | tr [:upper:] [:lower:])
    if [ $f != $lcf ]
    then
	if [ -f $f ]
	then
	    echo $f
	    mv $f $(echo $f | tr [:upper:] [:lower:]) 
	fi
    fi
done

cd ..

echo
echo You are ready to run nwserver
