Method to know if domain.com is in my server

Hello,

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

#bucle
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
        #comprobaciones
        if [ "$user" != "admin" ]; then
                #el usuario no es admin

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

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"
else
echo "The domain is not in this server"
fi

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"
else
echo "The domain $domain doesn't exist."
fi

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"
else
echo "The domain $domain doesn't exist."
fi

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"
else
echo "The domain $domain doesn't exist."
fi

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.

v-search-object domain.com

3 Likes
[email protected]:~# v-search-object dev.xxx.nu
USER     TYPE  KEY     RESULT       ALIAS
------                              
admin    web   DOMAIN  dev.xxx.nu

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 dev.xxx.nu , (COMMA) “PLAIN”
  2. v-search-object dev.xxx.nu (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 dev.xxx.nu “SUPER PLAIN”
or
4) v-search-object dev.xxx.nu 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:

https://docs.hestiacp.com/cli_commands/commands.html

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:
https://docs.hestiacp.com/cli_commands/commands.html#v-search-object

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.

3 Likes

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 mydomain.com web

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

  • web
  • mail
  • dns
  • *

when I run: ./v-search-domain-owner mydomain.com 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.