• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

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