From Kromonos, 2 Weeks ago, written in Bash.
Embed
  1. #!/bin/bash
  2.  
  3. domains=(
  4.         'domain.com'
  5.         'example.com'
  6. )
  7.  
  8. for domain in "${domains[@]}"
  9. do
  10.     keydir="/etc/opendkim/keys/$domain"
  11.     if [ -d "$keydir" ]
  12.     then
  13.       cd $keydir
  14.     else
  15.         mkdir -p $keydir
  16.         cd $keydir
  17.     fi
  18.     opendkim-genkey -r -d $domain
  19.     chown opendkim:opendkim default.private
  20.     echo "default._domainkey.$domain $domain:default:$keydir/default.private" >> /etc/opendkim/KeyTable
  21.     echo "$domain default._domainkey.$domain" >> /etc/opendkim/SigningTable
  22.     echo "$domain" >> /etc/opendkim/TrustedHosts
  23.     echo "$(cat $keydir/default.txt)" >> spfs.txt
  24. done