Postfix-hostname-to-reverse.../set-myhostname.sh

18 lines
321 B
Bash
Raw Normal View History

2021-03-24 01:11:11 +01:00
#!/bin/sh
IP=$(curl ifconfig.me)
curl_retval=$?
if [ $curl_retval -gt 0 ]; then
# TODO send warning email to postmaster here
exit 1
fi
2021-03-24 01:11:11 +01:00
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