#!/bin/sh

#Author: Ryan (ryan@afrihost.com

#Desc: This is for Ryan's use, a quick script to do lazy long winded things
#like delete checkcrons and anything else ryan does not want to type out
#repetively - :D

SLASH="================================="


echo "Checking for /root/tmp"
echo $SLASH 

ls /root/ |grep -q tmp

if [ $? = 0 ]
	then
		#echo "We have tmp"
		NUM=`ls /root/tmp |wc -l`
		echo "[ NOTICE ] - tmp has $NUM files"
		echo "[ QUESTION ] - Shell we remove yes or no"
		read REMOVE
			if [ $REMOVE = 'yes' ] ; 
				then 
				echo "[ NOTICE ] - removeing files ($NUM)- this may take some time"
					for i in `ls /root/tmp` ; do
						rm -rfv /root/tmp/$i
					done
				rm -rfv /root/tmp
				echo "[ NOTICE ] - remove finished"
				else
					echo "[ NOTICE ] - moving on"
			fi
		
	else
		echo "[ NOTICE ] - No tmp here, moving on"
		
fi


echo $SLASH
echo "Checking PureAuth"
echo $SLASH

ps aux > /root/.ps 2>/dev/null
cat /root/.ps |grep '/usr/local/afribin/servers/pureauth' > /root/.pureauth 2>/dev/null



if [ -s /root/.pureauth ];
        then
                echo "[ NOTICE ] - PureAuth is Cool"
        else
		echo "[ NOTICE ] - PureAuth is Broken"
			echo "[ QUESTION ] - Shell we run PUREAUTH fix yes or no"
			read PUREAUTH
				if [ $PUREAUTH = 'yes' ] ;
					then 
						cd /usr/local/afribin/
						./install.d//06_pure_ftpd.sh
						echo "[ QUESTION ] - Restarting"
						if [ `uname` = 'Linux' ] ;
							then 
								service pure-ftpd restart
							else
								/usr/local/etc/rc.d/pure-ftpd restart
						fi
					else
						echo "[ NOTICE ] - moving on"
				fi
fi

rm -f /root/.pureauth
rm -f /root/.ps
echo $SLASH

echo "Checking DoddgyProcess script in crons"

echo $SLASH

crontab -l |grep -q dodgyprocess
if [ $? = 1 ] ;
	then 
		echo "[ NOTICE ] - dodgyprocess not installed to crontab"
	else
		echo "[ GOOD ] - dodgyprocess installed to crontab"
fi

cat /etc/crontab |grep dodgyprocessif 
if [ $? = 1 ] ;
        then
                echo "[ NOTICE ] - dodgyprocess not installed to /etc/crontab"
        else
                echo "[ GOOD ] - dodgyprocess installed to /etc/crontab"
fi


echo $SLASH
echo "[ Final Note ] - All done have a great day"
echo $SLASH


