• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Domain status disabled/suspended unclear

Pleskie

Regular Pleskian
Hi,

I want to use CLI/bash to be able to enable, disable or suspend a domain. I am also trying to write a bash script that shows all enabled/disabled/suspended domains.

There seems to be a problem with the domain status though, or maybe I am doing something wrong?

I use "sudo plesk bin site --info [site name]" command to get all domain info, and then I use grep to get the "Domain status".

If a site is enabled, the domain status is: OK
If a site is suspended, the domain status is: Domain was suspended by administrator.

BUT

If a site is disabled, the domain status is: Domain was suspended by administrator. <= This is the exact same status as for a suspended domain.

As you can see, a suspended site and a disabled site share the exact same status, while they are 2 different things.

So how should I check (in bash) if a site is disabled instead of suspended? Am I doing something wrong or is this a bug in Plesk maybe?
 
You could distinguish between suspended and disabled domain statuses with a query like this:

# plesk db "select d.name, dp.val from domains d left join dom_param dp on d.id=dp.dom_id where d.name='example.com' and dp.param='turnOffAction'"
 
Thank you Igor, that is really helpful!

Last question: when I execute the query (without d.name) I get to see some sort of visual 'table'. But all I actually need is the value of dp.val without the visualtable. In other words, I only need the word 'disable' or 'suspend'. Is that somehow possible? Or is the only way to accomplish this to check if the output of the query contains the word disable/suspend?
 
Just use --disable-column-names option like:

# plesk db --disable-column-names -e "select dp.val from domains d left join dom_param dp on d.id=dp.dom_id where d.name='example.com' and dp.param='turnOffAction'"
 
@IgorG

By the way ... is there also a query I could use to directly get the status OK or suspended?

Right now I use "sudo plesk bin site --info [site name]" command to get all domain info, and then I use grep to get the "Domain status".

Is there an easier/better way to do this by using a query?
 
is there also a query I could use to directly get the status OK or suspended?
In table 'domains' you can see 'status' field. It is 0 when domain is Active and 16 if domain Suspended or Disabled.
 
Back
Top