Cannot rename sub-account/sub-domain: The following DNS sub-domains are using this server's zone file...

The whole problem is described here: https://www.virtualmin.com/node/57179

STEPS TO REPRODUCE:

1) add domain: domain.com
2) add sub-domain: sub1.domain.com
3) add sub-domain: sub2.domain.com
4) try to Change Domain Name for domain.com (parent)
Error: [Failed to change domain name : The following DNS sub-domains are using this server's zone file ...]

However, it says "fixed". But I have a 100% up-to-date Professional installation, and I get the same problem.
Basically I have like ~23 domains altogether (sub and normal), so not all that much.
For some unknown reason, Virtualmin added them with random names.

Like ...
- domainA.com has the admin user "domaina", the group "domaina", and the home folder of /home/domaina
- domainB.com has the admin user "domainb.com", the group "domainb.com", and the home folder of /home/domainb.com

There is no pattern, it seems utter random.
There is also a domain that used "admin" username for admin. God knows why. But it causes trouble with backup + re-import.
ANYWAY.
I wanna clear all this mess up and then migrate my installation. But I can't.
I go into a parent server, I go into Change Domain Name, and I get the error.

Please help? Or please fix?

Version numbers:
Webmin version 1.930
Usermin version 1.780
Virtualmin version 6.07 Pro

Status: 
Active

Comments

One alternative I found is to go into each sub-domain, Edit Virtual Server, untick "DNS", SAVE, and then you can rename parent. Make sure TO BACKUP ALL SUB DNS SETTINGS BECAUSE THIS WILL WIPE THEM!

Assigned: Unassigned ยป

Thanks for your report! I'm passing this along to Jamie for comment.

Ticket 57179 was only fixed in the sense that the work-around from comment #3 should now be possible. Unfortunately automatically renaming a domain and all it's sub-domains at once isn't yet supported.

My solution is as follows (forum slaughters syntax so will need to be fixed if you use this script):

#!/bin/bash CLIENTNAME=account # assuming /home/account OLDHOMEROOT=/home NEWHOMEROOT=/home/disk

for f in $(grep -r ${OLDHOMEROOT}/${CLIENTNAME} -F /etc | cut -d':' -f1); do sed -i "s|/${OLDHOMEROOT}/${CLIENTNAME}|${NEWHOMEROOT}/${CLIENTNAME}|g" ${f}; done

mv "${OLDHOMEROOT}/${CLIENTNAME}" "${NEWHOMEROOT}/${CLIENTNAME}" systemctl restart postfix dovecot apache2 webmin usermin proftpd