DATABASEURL="http://database.darkbot.net"
DATABASE="database.lst"
MASTER="master.file"
TDIR=".download"
clear
echo ""
echo "----------------------------------------------------"
echo "This script will query the darkbot.net server and"
echo "download some premade databases and make an info2.db"
echo "for you."
echo ""
echo "PLEASE NOTE: We now have a premade info2.db with a lot"
echo "    of topics already made. If you want a blank info2 with"
echo "    just bits of info, and you'd like to design your bot's"
echo "    personality, please continue. If you'd like a bot that"
echo "    is similar to the one seen on the examples page of the"
echo "    darkbot website, please go to http://darkbot.net/download.html"
echo "    and download the premade info2.db instead."
echo ""
echo "This program requires a few things in order to run"
echo "They are: lynx, gunzip, sort and uniq. If not present,"
echo "this script will fail."
echo "----------------------------------------------------"
echo -n "Hit enter to continue."
read PTR
echo "Getting directory listing of databases..."
lynx -source $DATABASEURL/$DATABASE > $DATABASE
echo ""
echo "------------------------------------"
echo "I found the following databases:"
LIST=`cat $DATABASE`
echo "$LIST"
echo "------------------------------------"
sleep 1
echo ""
echo "Do you want me to download them?"
echo ""
echo "Note: this will NOT update your existing"
echo "info2.db, so no need to worry"
echo "------------------------------------------------"
echo -n "Hit enter to continue, or ctrl+c to stop."
read PTR
echo ""
echo "Getting ready to download."
sleep 1
if test -r $TDIR; then
	echo "..."
else
	mkdir $TDIR
fi
set $LIST
echo "...downloading $1..."
lynx -source $DATABASEURL/$1 > $TDIR/$1
       echo "...downloading $2..."
       lynx -source $DATABASEURL/$2 > $TDIR/$2
       echo "...downloading $3..."
       lynx -source $DATABASEURL/$3 > $TDIR/$3
       echo "...downloading $4..."
       lynx -source $DATABASEURL/$4 > $TDIR/$4
       echo "...downloading $5..."
       lynx -source $DATABASEURL/$5 > $TDIR/$5
       echo "...downloading $6..."
       lynx -source $DATABASEURL/$6 > $TDIR/$6
       echo "...downloading $7..."
       lynx -source $DATABASEURL/$7 > $TDIR/$7
       echo "...downloading $8..."
       lynx -source $DATABASEURL/$8 > $TDIR/$8
       echo "...downloading $9..."
       lynx -source $DATABASEURL/$9 > $TDIR/$9
echo "Done."
echo ""
echo "----------------------------------------"
echo "The files should have been uncompressed while they"
echo "were downloaded. I am now going to combine all of"
echo "them into one master file."
cat $TDIR/$1 > $MASTER
cat $TDIR/$2 >> $MASTER
cat $TDIR/$3 >> $MASTER
cat $TDIR/$4 >> $MASTER
cat $TDIR/$5 >> $MASTER
cat $TDIR/$6 >> $MASTER
cat $TDIR/$7 >> $MASTER
cat $TDIR/$8 >> $MASTER
cat $TDIR/$9 >> $MASTER
echo "Done."
echo ""
echo "Making sure there are no dups in the database..."
uniq -u $MASTER > $MASTER.2
mv $MASTER.2 $MASTER
rm -rf $TDIR
echo "Done."
echo ""
ls -la $MASTER
echo "-----------------------------------------------------"
echo "You will find in the current directory, a file called"
echo "$MASTER. To use it, you will need to type this:"
echo "         mv $MASTER dat/info2.db"
echo "If you already have an existing info2, you can append"
echo "the $MASTER file to your info2, by typing:"
echo "         cat $MASTER >> dat/info2.db"
echo "-----------------------------------------------------"
echo "The end.         Questions? Email darkbot@darkbot.net"
