LittleDemon WebShell


Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
Path : /usr/local/bin/
File Upload :
Command :
Current File : //usr/local/bin/dxm.self_rotate

#!/bin/bash

# DXM self rotate script
# Pavel Piatruk, 2011
# http://www.nksupport.com

. /etc/dxm/dxm.conf
export HOME=/root/

export LIST=/var/tmp/dxm.rotate.lst

export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[ "$DOROTATE" = 1 ] || echo "enable DOROTATE, exit"  | tee -a $ROTATELOG
[ -n "$ROTATELOG" ] || echo "configure ROTATELOG , exit"  | tee -a $ROTATELOG

if [ $DOFTP == 1 ] && ! lftp $FTPHOST -e "cd $FTPDIR; exit"
then    echo "ROTATE CRITICAL - cant connect to $FTPHOST or cd to $FTPDIR" | tee $STATUSROTATE | tee -a $ROTATELOG
exit
fi


echo | tee -a $ROTATELOG
echo | tee -a $ROTATELOG
echo "=== @@@@@ `date` START rotate script in `pwd`" | tee -a $ROTATELOG


echo "=== obtaining remote listing :" | tee -a $ROTATELOG
lftp $FTPHOST/$FTPDIR -e 'cls *tgz *lst; exit' |sort -g > $LIST
cat $LIST | tee -a $ROTATELOG
echo "=== done " | tee -a $ROTATELOG


cp $LIST $LIST.old

echo "=== start processing SLOTS"  | tee -a $ROTATELOG
echo -e "$SLOTS"     | sed 's@^\(.*\) \(.*\)$@ grep -E "00.tgz$" $LIST | awk -F. '\''{if (($1>="\1") \&\&  ($1<="\2")) \
	print "echo file "$1" satisfies SLOT \1..\2, saving; sed /"$1".00.tgz/d -i \$LIST "}'\'' | \
	sort|tail -n 1@'  | bash|bash | tee -a $ROTATELOG
echo "=== end processing"  | tee -a $ROTATELOG


echo "=== start processing SLOTSINCR"  | tee -a $ROTATELOG
echo -e "$SLOTSINCR" | sed 's@^\(.*\) \(.*\)$@ grep -E "00.tgz$" $LIST | awk -F. '\''{if (($1>"\1")  \&\& ($1<="\2")) \
	print "echo file "$1" satisfies SLOT \1..\2, saving; sed /"$1"....tgz/d -i \$LIST "}'\'' | \
	sort|tail -n 1@'  | bash|bash | tee -a $ROTATELOG
echo "=== end processing"  | tee -a $ROTATELOG


echo "=== difference between old & new lists are (required files are removed)" | tee -a $ROTATELOG
diff $LIST.old $LIST | tee -a $ROTATELOG

echo "=== now lets purge nonrequired files beyond SLOTs" | tee -a $ROTATELOG
for F in `cat $LIST` 
do
echo "== purging $F " | tee -a $ROTATELOG
lftp $FTPHOST/$FTPDIR -e "rm $F; exit"
done

echo "=== obtaining remote listing :" | tee -a $ROTATELOG
lftp $FTPHOST/$FTPDIR -e 'cls *tgz *lst; exit' |sort -g  | tee -a $ROTATELOG
echo "=== done " | tee -a $ROTATELOG



echo "=== @@@@@ `date` STOP rotate script" | tee -a $ROTATELOG



echo ROTATE OK > $STATUSROTATE




LittleDemon - FACEBOOK
[ KELUAR ]