cPanel - Script to fix permissions/ownership under a reseller

Fix permissions/ownership under a reseller

                             I recently had an issue with incorrect ownership and permissions  of all files under a reseller in cpanel after the manual migration from a Kloxo and plesk server.
I created the following script to fix permissions under a reseller.

You just copy the following script in a file, then

# chmod +x

Give the reseller user name in the <reseller> field when running the If no parameter is given, it will fix permissions/ownership of all accounts in the server.

# sh <reseller>


echo -e "Fixing Permissions of account under $reseller \n"
for i in `grep -rl "OWNER=$reseller" /var/cpanel/users | cut -d/ -f5`
if [ "$i" != "root" ]; then
chown -R $i:$i /home/$i
chown $i:nobody /home/$i/public_html
chown $i:mail /home/$i/etc 
find /home/$i/public_html/ -type d -exec chmod 755 "{}" \;
find /home/$i/public_html/ -type f -exec chmod 644 "{}" \;
chmod 750 /home/$i/etc /home/$i/public_html
echo $i


That's it...