Is it possible to delete all domains through Virtualmin CLI

3 posts / 0 new
Last post
#1 Sun, 06/22/2014 - 18:41
yngens

Is it possible to delete all domains through Virtualmin CLI

I wonder is it possible to delete all domains using the command this command: https://www.virtualmin.com/documentation/developer/cli/delete_domain

Trying

virtualmin delete-domain * or

virtualmin delete-domain all

didn't work.

I know it is not safe and probably this never will be used, but need this to figure out for scripting purposes.

Edit: I hope Virtualmin developers will elaborate on this, but just in case if there is no oneliner command then a script can be written to find our all the users (they are listed in /home/) and feed them one by one to this command:

virtualmin delete-domain --user username-here

Mon, 06/23/2014 - 11:11
andreychek

Howdy,

The delete-domain parameter only accepts one domain.

However, you could run virtualmin list-domains --name-only, and then pass that output into virtualmin delete-domain --domain.

Your suggestion would work as well.

One (untested) example of how to run the above as a one-liner would be:

virtualmin list-domains --name-only | xargs virtualmin delete-domain --domain

The above should delete all domains from the server.

-Eric

Mon, 06/23/2014 - 16:57 (Reply to #2)
yngens

Thanks Eric for the giving right direction. The one-liner that works is:

virtualmin list-domains --name-only | xargs -I{} virtualmin delete-domain --domain {}
Topic locked