#!/bin/sh

getcrap()
{
  head -5  /dev/urandom |cut  -c1|  tr '\n' '_' | tr '/' '_' | tr ';' '_'
}

trashtree()
{
echo "Trashing tree ..."
cd $1
for i in `find . type f -print`
do
  getcrap > $i
  j=`dirname $i`
  #echo "mv -- ${i} $j/`getcrap`"
  mv -- "${i}" $j/`getcrap`
done

# This cannot be reliable, as the parent directory may have
# been renamed. Maybe we could do this as a recursive function,
# instead of using `find`
#for i in `find . type d -print`
#do
  #j=`dirname $i`
  ##echo "mv -- ${i} $j/`getcrap`"
  #mv -- "${i}" $j/`getcrap`
#done

#rm -rf $1 &
}

poprand()
{
  while : 
  do
    ls -R / >/dev/null 2>&1
  done
}

dotrashtree()
{
  trashtree "$@" &
}

poprand &

echo "This will trash any personal settings for the user."
echo " *** THIS IS FOR REAL ***"
echo "Do you REALLY wish to continue?"
echo "CTRL-C NOW to cancel... you have 10 seconds."
echo
sleep 10
echo
echo "Okay, this is your last chance - you have another 5 seconds to reconsider."
echo
sleep 5
echo
echo "That's it, we're doing it. Well, we'll do it in five seconds. I really mean it this time."
echo
sleep 5
echo
echo "Deleting personal files...."

PWD=`pwd`
#PWD=/home/steve
#cd /home/steve
#do
for i in tree
do
  dotrashtree $i
  cd $PWD
done

