#!/bin/sh
#
# mkpoprc-1.0.1 by Andrew Costa, the same bored taxi driver
# who wrote 'note' and 'convt'.  I must find something
# better to do with my life.  
#
# Oh, yeah - <seagull@osiris.isys.ca>
#
# This script is for setting up your .poprc with
# popclient-3.1, a nice mail client.
# Buy its author a beer if you see him :)
#
if [ "$MAIL" != "" ]; then
LocalFolder="$MAIL"
else
LocalFolder=~/mbox
fi
if [ -f ~/.poprc ]; then
echo -n "Replace existing .poprc? (y/N) "
read RESPONSE
if [ "$RESPONSE" = "y" ]; then
mv ~/.poprc ~/.poprc.old
else
echo "This entry will be appended to your .poprc"
fi
fi
echo -n "Remote username? "
read USR
echo -n "Remote password? "
read PASS
echo -n "Remote mail site? "
read SITE
echo -n "Protocol? (one of: pop2, pop3, imap) "
read PROTO
echo -n "Sure you want to do this? (y/N) " 
read ANSWER
if [ "$ANSWER" = "y" ]; then
if [ -f ~/.poprc ]; then
echo > ~/.poprc.tmp
fi
echo "server $SITE \\" >> ~/.poprc.tmp
echo "proto $PROTO \\" >> ~/.poprc.tmp
echo "user $USR \\" >> ~/.poprc.tmp
echo "pass $PASS \\" >> ~/.poprc.tmp
echo "localfolder $LocalFolder" >> ~/.poprc.tmp
cat ~/.poprc.tmp >> ~/.poprc
chmod 600 ~/.poprc
rm -f ~/.poprc.tmp
echo "Entry completed."
echo
echo "The command  popcli  will retrieve all of your mail."
echo "The command  popcli [host]  will retrieve mail from [host],"
echo "if [host] is named in your .poprc file."
echo
fi
