#/bin/sh

#
# Use this script to update all userfiles created by shirc < 0.9
# to new directory format.
#

if [ -z "${SHIRC_CHDIR}" ]; then
        SHIRC_CHDIR=/tmp/shirc
fi

echo "Scanning ${SHIRC_CHDIR} directory (set SHIRC_CHDIR to change this)."

# translate old userfile to new userdir
cd ${SHIRC_CHDIR}
for userfile in `find . -type f -name '*.users'`; do
	channel=`basename $userfile .users`
	logfile=`echo $userfile | sed 's/\.users/\.log/'`
	echo '*** WARNING! user file is being updated, shirc restart is suggested' >> $logfile
	echo "Updating channel $channel"
        mkdir /tmp/$$
        for u in `cat ${userfile}`; do
                touch /tmp/$$/${u}
        done
        rm ${userfile}
        mv /tmp/$$ ${userfile}
done
