Created
September 25, 2015 16:50
-
-
Save rushipkar90/4af4e93437a3be24b22c to your computer and use it in GitHub Desktop.
reseller_autoterminate.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directory to store log files in | |
DST=/root/autotermination_logs | |
# Create DST if it doesn't exist | |
if [ ! -d "$DST" ]; then | |
mkdir -p $DST | |
fi | |
date_diff() { | |
echo $(((`date -d $1 +%s`-`date +%s`)/(24*3600))); | |
} | |
for s_lst in `grep -v userowners /etc/trueuserowners|awk '{print $2}'|sort|uniq` | |
do | |
if [ -f /var/cpanel/suspended/$s_lst ] && [ `du -b /var/cpanel/suspended/$s_lst | awk '{print $1}'` -eq 0 ] && [ `date_diff \`date +%Y-%m-%d -r /var/cpanel/suspended/$s_lst\`` -le -30 ]; | |
then | |
echo -e "\n\n\nTerminating $s_lst on at `date +%r`" >> $DST/terminated-`date +%F`.txt | |
curl -k -H "Authorization: WHM root:`cat ~/.accesshash | tr -d "\n"`" 'https://localhost:2087//xml-api/terminatereseller?reseller='$s_lst'&terminatereseller=1&verify=I%20understand%20this%20will%20irrevocably%20remove%20all%20the%20accounts%20owned%20by%20the%20reseller%20'$s_lst >> $DST/terminated-`date +%F`.txt | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment