• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

/usr/local/psa/bin/dns --info <domain> gives output if DNS control is off

Frater

Regular Pleskian
We have several Plesk servers and many domains.
One Plesk server normally handles domains with DNS-control (though not all) and the others have foreign DNS-control.

Today I changed the MX-record of a domain on the Plesk-server and found out a bit later that this server didn't have DNS-control. Normally I would have turned DNS-control off on this server, but apparently I forgot this when I initially configured this domain.

Now I want to write a little script in bash that checks if DNS-control is turned off if the DNS is foreign.

This would have been easy if the CLI-utility /usr/local/psa/bin/dns --info <domain> would give me the info if DNS-control is turned off. I'm able to turn it off or on with this utility, but I can't see its current status.

When DNS-control is turned off for a specific domain it will still give the records it would have if it had control.
The utility shouldn't do this.


Could this be changed?

Anyone knows how I can query the 'psa' database for this setting?
 
Last edited:
mysql> select status from dns_zone where name='domainnn.fr';
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)

~# /usr/local/psa/bin/dns --off domainnn.fr
SUCCESS: Switching DNS state for Domain 'domainnn.fr' complete.

mysql> select status from dns_zone where name='domainnn.fr';
+--------+
| status |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
 
Thanks Igor for this fast reply.
I immediately started to write the script...

As you can see I'm better with bash than with mysql
I just copied the mysql statement from an example.
I know that the one that should merely get the domains is wrong.
Maybe you can give the proper one.

The script is working though!!!


cat pleskdns
Code:
#!/bin/bash

HT=`echo -en '\t'`

TMP1=`mktemp`
TMP2=`mktemp`
TMP3=`mktemp`
TMP4=`mktemp`

# get IP's of this server
ifconfig | egrep -o 'inet addr:[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | awk -F: '{print $2}' >/tmp/IPS

# get all hosted domains
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "SELECT domains.name FROM domains, Limits WHERE domains.limits_id = Limits.id ORDER BY domains.name ASC; " | egrep '[a-z0-9.-]+\.[a-z]+$' | sort | uniq >${TMP1}

if [ ! -z "$1" ] ; then
  if grep -qi "$1" ${TMP1} ; then
    grep -i "$1" ${TMP1} >${TMP2}
    cat ${TMP2} >${TMP1}
  else
    echo "Domain $1 not found on this server!" >&2
    exit 1
  fi
fi

while read DOMAIN ; do

   DNS_OFF=$(mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "select status from dns_zone where name='${DOMAIN}';" 2>/dev/null | tr -cd '0-9')

   host -t NS ${DOMAIN} | grep -o 'name server .*' | awk '{print $3}' >${TMP2}

   while read NS ; do
     host -t A ${NS} | grep -o 'has address .*' | awk '{print $3}' >>${TMP3}
   done <${TMP2}

   THIS_SERVER_IS_DNS=0
   while read IP ; do
     grep -q "^${IP}$" ${TMP3} && THIS_SERVER_IS_DNS=1
   done < /tmp/IPS

   if [ "${DNS_OFF}" = "0" ] ; then
     if [ "${THIS_SERVER_IS_DNS}" = "0" ] ; then
       echo -e "DNS is turned on for ${DOMAIN}, but should be turned OFF\n\tThese servers are doing it:"
       cat ${TMP2} | sed "s/.*/${HT}${HT}${HT}${HT}${HT}&/g"
       echo -e '\n'
     fi
   fi
done<${TMP1}

rm ${TMP1}
rm ${TMP2}
rm ${TMP3}
rm ${TMP4}
 
Back
Top