Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Created September 25, 2015 16:30
Show Gist options
  • Save rushipkar90/60888cef96e8a1ac9f09 to your computer and use it in GitHub Desktop.
Save rushipkar90/60888cef96e8a1ac9f09 to your computer and use it in GitHub Desktop.
dms_cron.sh
#! /bin/bash
echo > restorehome.txt;
echo > restoremail.txt;
CP_ACCOUNTS=`ls -1A /var/cpanel/users/ | grep -v "root"`
for user in `echo -n $CP_ACCOUNTS`
do
#echo $user;
maindomain=`cat /etc/trueuserdomains | grep -w "$user$" | cut -d : -f1`;
homedir=`cat /var/cpanel/userdata/$user/$maindomain | grep homedir | cut -d / -f2`;
#echo "$homedir";
if [ "$homedir" = home ]; then
find /home/*/ -maxdepth 1 -name .dms-restore-home >> restorehome.txt;
find /home/*/mail -maxdepth 1 -name .dms-restore-mail >> restoremail.txt;
else
if [ "$homedir" = home2 ]; then
find /home2/*/ -maxdepth 1 -name .dms-restore-home >> restorehome.txt;
find /home2/*/mail -maxdepth 1 -name .dms-restore-mail >> restoremail.txt;
fi
fi
done
for i in `cat restorehome.txt`; do
Username=`echo $i | cut -d / -f3`;
echo $Username;
chown $Username.mail /home/$Username/mail;
chown $Username.nobody /home/$Username/public_html;
/scripts/mailperm $Username
rm -rf $i;
done
for j in `cat restoremail.txt`; do
Username=`echo $j | cut -d / -f3`;
echo $Username;
chown $Username.mail /home/$Username/mail;
/scripts/mailperm $Username
rm -rf $j;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment