Method to know if is in my server


I already have a method to have the full domain list with their corresponding users:

for user in $($HESTIA/bin/v-list-users | cut -d' ' -f1 | tail -n +3); do
        for domain in $($HESTIA/bin/v-list-web-domains $user  | cut -d' ' -f1 | grep "\."); do
        if [ "$user" != "admin" ]; then
                #el usuario no es admin

                if [ ! -z "$domain" ]; then
                echo "$user,$domain" >> $file

Then I can see if grep found the domain or not:

cat $file | grep ",$domain" > dev/null
if [ "$?" -eq "0" ]; then
echo "The domain is in this server"
echo "The domain is not in this server"

But it is inefficient to check all of the domains so to speed things up, I would like to test if a domain exists before running this bit of code.

If I knew the username, it would be trivial because I could test:

if [ -d "/home/$username/web/$domain"]; then
echo "The domain $domain exists"
echo "The domain $domain doesn't exist."

But I don’t know the username yet.
The only thing that I can try is to test $domain = $username and then if I am lucky I know the username because it is the same as the domain.

I was thinking about this solution:

if [ -f "/var/log/nginx/domains/$domain.bytes" ||  -f "/var/log/apache2/domains/$domain.bytes"]; then
echo "The domain $domain exists"
echo "The domain $domain doesn't exist."

But it only tells me if the domain has existed in this server. Maybe it has been moved.

I have thought about testing:

if [ -e "/etc/nginx/conf.d/domains/$domain.conf" ]; then
echo "The domain $domain exists"
echo "The domain $domain doesn't exist."

Is there a better method that you can think of? use -L because it is a link or check both if is a link and exists.


[email protected]:~# v-search-object
admin    web   DOMAIN

Adding plain makes it even better

One of these days I’d LOVE to convince you guys that we need to have better documentation for these macros that are available.

I don’t even know if Macros is the right term.
He said ‘Adding plain makes it even better’.

I think that we need DETAILED examples of every argument, what it does, what it means, and related macros that are often used in conjunction with the first macro.

For example, ‘Adding plain makes it even better’.
Does he mean:

  1. v-search-object , (COMMA) “PLAIN”
  2. v-search-object (SPACE) “PLAIN”

when to arguments have quotes around them. only when there are spaces in that value?
if the argument was ‘SUPER PLAIN’
then we would use
3) v-search-object “SUPER PLAIN”
4) v-search-object SUPER PLAIN

I don’t know if there are supposed to be quotes around values.
I LOVE hestiacp, it is probably my favorite piece of software of ALLL TIME.

I just think that we need 10x greater, more detailed examples for EVERY ARGUMENT, What it SAYS, and What it MEANS and Who, What, When Where and WHY we should use a certain value.

I’m not trying to be negative. I just always look at the CLI examples, and it takes me 3-4 times to do something correctly most of the time.

1 Like

It is always v-search-object “search” plain

If bash requires quotes it is required how ever it is not a bad idea to use them on default. Please note that ’ quotes mean something different then " and usualy single quotes is what you want.

Al “Existing” command are documented in:

Due to the fact there are +450 command the list is one yes we know

The list is regularly updated so it may sometimes out of date…

But use the search function:

Or check the source code:

Yes the documentation needs to be improved. But we are limited on time what we can spend on. And every second spend on Hestia is time we can’t spend on our clients so we prioritise our work load.


Thank you for that info.

I just still know that JSON and PLAIN are arguments to this function. What are OTHER values that can be pasted into this function? SPREADSHEET? is that a valid option? CSV?

I’m not trying to be a jerk. I just wish that the examples were 10x more detailed.
I swear, HestiaCP is my favorite piece of software of all time, ever.

I don’t know how to READ much of this source code sometimes, really!

Thank you @eris for your pointer.

There is this built-in function that is even better:
./v-search-domain-owner domain [type]
so that when you search specifically for a web domain you use it this way:
./v-search-domain-owner web

In the source code I can see 4 types of arguments for “type”:

  • web
  • mail
  • dns
  • *

when I run: ./v-search-domain-owner web
$? turns 0 if it found the domain and prints the name of the owner
In case it doesn’t exist, it returns 3.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.