How to terminate all reseller's accounts but leave DNS on server?

electric

Well-Known Member
Nov 5, 2001
785
9
318
Hello,

We have moved one of our reseller's to a different server within the DNS cluster that we have set up.

How can we terminate all their accounts on the old server, but leave the DNS in place?

ie: We do not want to kill the zonefiles along with the accounts, since I think that would also remove the DNS from the DNS cluster... causing their sites on the new server to go down since now there would be no DNS.

In other words, how do we terminate all the resellers accounts, but "Keep Dns Zone (needed if you have moved a domain between servers in the same dns trust relationship, and wish to remove the old domain)".

This option is not available in the reseller termination screen in WHM.
 

electric

Well-Known Member
Nov 5, 2001
785
9
318
BTW - this reseller has over 400 accounts. So manually selecting them one-by-one on the "Terminate Multiple Accounts" screen (along with the checkbox to keep DNS) doesn't seem like a good idea.

Thanks.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

All right, first grab a list of all the accounts and put that list into a file called /root/acctlist:

Code:
grep -v 'root\|#' /etc/trueuserowners | grep resellerusername | cut -d: -f1 > /root/acctlist
Please replace resellerusername with the reseller's username. For example, here's what I get on my machine when I run this where the users are the accounts under my endar reseller:

Code:
[email protected] [/]# grep -v 'root\|#' /etc/trueuserowners | grep endar | cut -d: -f1 > /root/acctlist
[email protected] [/]# cat /root/acctlist
ratings
endar
Now that you have a list of users, you can run the following to loop through that list to terminate the accounts but still keep the DNS:

Code:
for i in `cat /root/acctlist` ;do /usr/local/cpanel/scripts/killacct $i --killdns=n --force ;done
This is a very powerful command as it will remove the accounts entirely without any prompt to ask if you want to do so due to the --force portion. Please only use this if you are absolutely positive that a) you have backups available if anything goes wrong for all accounts, b) the list of accounts in /root/acctlist is the correct list of accounts owned by that reseller.

Thanks!