How to check if domain is disabled with Virtualmin CLI

Currently we have to do something like this:

partial="$(echo $dom | cut -c1-30)"
disabled="$(virtualmin list-domains --domain $dom --disabled | grep $partial)"
if [ ! -z "$disabled" ]; then
  echo "Disabled"
fi

because the virtualmin list-domains --domain $dom --disabled seems to output only partially cut (30 symbols) domain name.

However, I believe such fairly simple task as checking domain status should be available through CLI directly as, for example:

virtualmin list-domains --domain $dom --status

that would output either "Enabled" or "Disabled". I don't know if this feature request will be accepted or not, in either way would be nice to update the documentation page on https://www.virtualmin.com/documentation/developer/cli/list_domains, which gives only these options:

virtualmin list-domains [--multiline | --name-only | --id-only |
                         --simple-multiline | --user-only | --home-only]
                        [--domain name]*
                        [--user name]*
                        [--id number]*
                        [--with-feature feature]
                        [--without-feature feature]
                        [--alias | --no-alias | --subserver |
                         --toplevel | --subdomain]
                        [--plan ID|name]
                        [--reseller name | --no-reseller |
                         --any-reseller]

Compare with what the command gives on CLI:

virtualmin list-domains [--multiline | --name-only | --id-only |
                         --simple-multiline | --user-only |
                         --home-only | --file-only]
                        [--domain name]*
                        [--user name]*
                        [--mail-user name]*
                        [--id number]*
                        [--with-feature feature]
                        [--without-feature feature]
                        [--alias domain | --no-alias]
                        [--subserver | --toplevel | --subdomain]
                        [--parent domain]
                        [--plan ID|name]
                        [--template ID|name]
                        [--disabled | --enabled]
Status: 
Active

Comments

Title: How to check if domain disabled with Virtualmin CLI » How to check if domain is disabled with Virtualmin CLI

You can use the --name-only flag to list-domains to get just the full domain names, rather than the human-friendly table format.

Thanks James, I know that and, unfortunately, that doesn't answer the initial question in the title of this request.

You could use a command like :

virtualmin list-domains --domain yourdomain.com --disabled

If the domain is disabled, this will output the name. Otherwise, it will output nothing.

Now, read my initial post - I used exactly that pattern and it has its own flows. It will not output domian name, virtualmin list-domains --domain $dom --disabled will output only partially cut (30 symbols) domain name. Try with long domain names.

My mistake, the command should be virtualmin list-domains --domain yourdomain.com --disabled --name-only

Thanks for the hint as your suggestion makes our additional script some simpler. However, still wouldn't be nice to have something like

virtualmin list-domains --domain $dom --status

which would output either "Enabled" or "Disabled"?

If it complicates things don't bother as we already have solution for our use case. I am just thinking to make it better for Virtualmin CLI.

Sure, but I want to keep the API simple and consistent, rather than adding too many special cases.