#!/bin/sh

#< Check ftp logfile for failures, etc

_FTP_LOG=/var/log/vsftpd.log

if [ `id -u` != 0 ]; then
   echo "You must be root to run this script!" && exit 1
fi

if [ "$#" != 0 ]; then
   echo "USAGE: `basename $0`"
fi

echo -n "Do you just want to view the entire log? [y|n] "
read reply
case $reply in
  [yY]) more $_FTP_LOG && exit 1
        ;;
  [nN]) ;;
  *   ) echo "${reply}??? I'll assume you meant no"
        ;;
esac

echo -e "\n\n"

echo "Last 10 Logins"
echo "--------------"

grep '^.*LOGIN' $_FTP_LOG | tail

echo "Press enter to continue...."
read dummy
echo -e "\n\n"

echo "Last 10 failed events"
echo "---------------------"

grep '^.*FAIL' $_FTP_LOG | tail
exit 0