#!/bin/sh

# Author: Ryan

# Descp: Simple script to change the owner of the user account to magicreg
# or $Owner

OWNEER="magicreg"
CPUSERDIR="/var/cpanel/users/"
OWNERCHANGE="root"

DATE=`date +%Y-%m-%d-%H%m`

echo ""
echo "I am backuping up $CPUSERDIR"
echo ""

tar -zpcf /var/cpanel/$DATE-users.tgz $CPUSERDIR

for i in `ls $CPUSERDIR` ; do

ASOWNER=`cat $CPUSERDIR$i |grep OWNER | awk -F '=' '{ print $2 }'`

if [ "$ASOWNER" = "$OWNERCHANGE" ] ;
	then
		echo "Modifing $i"
		cat $CPUSERDIR$i > /root/.xxx 
		cat /root/.xxx | sed -e s/$OWNERCHANGE/$OWNEER/g > $CPUSERDIR$i
		echo "Done..."
		#cat $CPUSERDIR$i |grep root | sed -e s/$OWNERCHANGE/$OWNEER/g
#	else
#		echo "Nothing to be done for $i"
fi

done




