• 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

Command line cli DNS Template Changes warning

Nomadturk

Basic Pleskian
OK,

I have a what seems like a problem.

I'm using this script as a cron to generate DKIM keys for the domains I have. It's an easy script.
And it does it's job just OK. I have the necessary software installed and configured.

The way it works is:

The script check if the domain in queue has a record for it.
IF it doesn't,
OpenDKIM generates a one time DKIM record for mail._domainkey that I am entering to my dns records for all the domains I have.

After creating the DKIM record, it checks and deletes mail._domainkey records if there's any.
Then adds the generated DKIM to plesk dns zones and disables/enables greylisting to create the appropriate dns entry.

IF it does have a DKIM recors on the hdd already,
then it removes
mail._domainkey​
and
TXT o=-​
entries.


After that it basically adds the already generated DKIM record and it disables/enables the greylisting for each domain in order to recreate "TXT o=-"

Up till here, it works fine. I can see these entries when I check the DNS Settings.
They are there.

But whenever I run this script either via cron or manually, I get an error message on my panel:
(You can check the screenshot as well)

ve5isk.png

Code:
Warning: The DNS zone was modified. If you would like to apply DNS template changes to this zone, either click the 'Apply DNS Template Changes' button on this page or choose the 'Apply the changes to all zones' option in Server Administration Panel > Tools & Settings > DNS Template Settings > Apply DNS Template Changes.



and unless I manually click "Apply DNS Template Changes" for EVERY SITE it doesn't go away.

So, I was wondering, is there a way to scriptize that command? Or how to prevent it?



This is the command I use to generate DKIM and add it to Plesk database, also if any such record exists, delete and re-write it:

Code:
#!/bin/sh

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
mysql="${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa"

query="select name from domains;"
domains=`echo $query | $mysql `

for i in ${domains}; do
    echo "Processing $i"
cwd=`pwd`
opendkim="/etc/opendkim"
location="$opendkim/keys/$i"

#cd $opendkim
# If there is no DKIM record for the domain, create it.
# And insert the records to the dns zone.
if [ ! -d $location ]; then
mkdir -p "$location"
cd "$location"
opendkim-genkey -d $i -s mail
chown opendkim:opendkim *
chown opendkim:opendkim "$location"
chmod u=rw,go-rwx *
echo "No DKIM records found for $1, generating DKIM"
echo "$i $i:mail:$location/mail.private" >> /etc/opendkim/KeyTable
echo "*@$i $i" >> /etc/opendkim/SigningTable
echo "$i" >> /etc/opendkim/TrustedHosts
echo "mail.$i" >> /etc/opendkim/TrustedHosts
echo
echo "The automated process will add this, disregards the line below."
echo "Add this TXT value to dns zone of  $i"
echo
cat "$location/mail.txt"
echo
echo "DKIM Records for $i has been generated"
echo "Adding DKIM records to Plesk"
perl -p -i -e 's/\R//g;' $location/mail.txt
record=$(awk -F '"' '{ print $2 $4 }' $location/mail.txt)
/usr/local/psa/bin/dns -a "$i" -txt "$record" -domain mail._domainkey
echo
echo "Activating/Reactivating DomainKey for $i"
/usr/local/psa/bin/domain_pref -u "$i" -sign_outgoing_mail false
/usr/local/psa/bin/domain_pref -u "$i" -sign_outgoing_mail true


else

# For existing domains, first clear the records.
# Then add the records again from the text file.
#echo "Adding DKIM records to Plesk"
perl -p -i -e 's/\R//g;' $location/mail.txt
record=$(awk -F '"' '{ print $2 $4 }' $location/mail.txt)

echo "Cleaning old entries"
/usr/local/psa/bin/dns --del "$i" -txt "" -domain mail._domainkey
/usr/local/psa/bin/dns --del "$i" -txt "o=-" -domain _domainkey
echo "Re-adding DKIM entries for domain $1"
/usr/local/psa/bin/dns -a "$i" -txt "$record" -domain mail._domainkey
echo ""
echo "Activating/Reactivating DomainKey for $i"
/usr/local/psa/bin/domain_pref -u "$i" -sign_outgoing_mail false
/usr/local/psa/bin/domain_pref -u "$i" -sign_outgoing_mail true
fi
done
 
Hi Nomadturk,

did you try to end your script with

/usr/local/psa/admin/sbin/dnsmng --update "$i"
in order to save your modifications as well in the psa - database?
 
Does anybody know what's the exact command of "Apply DNS Template Changes"
(Not the dns template one, the one that is there on every domain's dns zone)

/usr/local/psa/admin/sbin/dnsmng --update "$i"

doesn't do trick.
 
Back
Top