#!/bin/bash
#

apt-get update --allow-releaseinfo-change 1>/dev/null 2>/dev/null

echo "`date` : Cleaning up LOGS"
echo "`date` : Cleaning up LOGS" >> /var/log/logclean.log

find /var/log/ -type f | grep .gz$ | xargs rm 1>/dev/null 2>/dev/null
find /var/log/ -type f | grep .1$ | xargs rm 1>/dev/null 2>/dev/null

SPCTMP=`df -h /tmp | awk '{print $5}' | grep -vi [a-z] | sed "s/%//g"`
if [ $SPCTMP -gt 90 ] ; then
	/etc/init.d/ipchanged.init stop
	pkill -9 ipchanged
	rm /tmp/ipchanged.lock
	/etc/init.d/ipchanged.init start
fi


LIST=`find /var/log/ -type f | grep log$`

for i in $LIST ; do
	SIZE=`du -sm $i | awk '{print $1}'`
	if [ $SIZE -gt 1 ] ; then
		> $i
	fi
done
