#!/bin/sh eval `ckconfig -s || /var/local/stat/bin/ckconfig -s` eval `$binDir/configuration` tmp=$tmpDir/.mail PATH=$binDir:$PATH export PATH echo "Starting ChangeStat..." if [ "$1" = "" ] ; then users=`$binDir/ulist` else users=$1 fi for user in $users do change=0 class=`grep -w $user $UserStatus | awk '{print $2}'` status=`grep -w $user $UserStatus | awk '{print $3}'` date=`grep -w $user $UserStatus | awk '{print $4}'` saldo=`grep -w $user $Account | awk '{printf ("%d",$5) }'` > /dev/null if [ "$class" = "normal" ] ; then if [ "$status" = "closed" ] ; then if [ $saldo -gt 0 ] ; then #echo "From: StatServ " > $tmp #echo "Subject: Open '"$user"', please." >> $tmp #echo "To: "$StatMaster >> $tmp #echo >> $tmp #/usr/sbin/sendmail -f statserv@ineco.ryazan.su $StatMaster < $tmp $binDir/setstatus $user open fi fi if [ "$status" = "warned" ] ; then if [ $saldo -gt 0 ] ; then change=1 status="open "`date +%d\.%m\.%y` fi if [ $saldo -lt 0 ] ; then closedate=`$binDir/plusdate 8 $date | awk '{print $1"."$2"."$3}'` date=`date +%d\.%m\.%Y` $binDir/comparedate $date $closedate if [ $? -eq 1 ] ; then if [ "$status" != "closed" ] ; then #echo "From: StatServ " > $tmp #echo "Subject: CLOSE '"$user"', PLEASE." >> $tmp #echo "To: "$StatMaster >> $tmp #echo >> $tmp #/usr/sbin/sendmail -f statserv@ineco.ryazan.su $StatMaster < $tmp $binDir/setstatus $user closed fi fi fi fi if [ "$status" = "notify1" -o "$status" = "notify2" -o "$status" = "notify3" ] ; then if [ $saldo -gt 100000 ] ; then change=1 status="open" chgdate=`date +%d\.%m\.%y` fi fi if [ $change -eq 1 ] ; then # userst=`grep -w $user $UserStatus` # grep -v -w $user $UserStatus > $tmp # echo $userst | awk '{printf ("%s %s",$1,$2)}' >> $tmp # echo -n " "$status" "$chgdate >> $tmp # echo $userst | awk '{printf (" %s\n",$5)}' >> $tmp # sort $tmp > $UserStatus # rm -f $tmp $binDir/setstatus $user $status fi fi done echo "ChangeStat finished."