Postfix-hostname-to-reverse.../set_myhostname.sh
The_Lie 2b87c4b01c Update 'set_myhostname.sh'
Removed some testing code
2021-03-24 01:14:45 +01:00

17 lines
315 B
Bash

#!/bin/sh
IP=$(curl ifconfig.me)
curl_retval=$?
if [ $curl_retval -gt 0 ]
# TODO send warning email to postmaster here
exit 1
fi
host_answer=$(host "$IP")
rev_dns="${host_answer##* }"
rev_dns="${rev_dns%.}"
echo "Rev. DNS is: $rev_dns"
sed -e "s/^myhostname.*/myhostname = $rev_dns/" -i /etc/postfix/main.cf