Skip to content

Instantly share code, notes, and snippets.

@agarzon
Created October 24, 2014 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agarzon/4b28e3a57a55c39d0cc1 to your computer and use it in GitHub Desktop.
Save agarzon/4b28e3a57a55c39d0cc1 to your computer and use it in GitHub Desktop.
Automatically set up the Plesk DNS to work with Google Apps in a domain
#!/bin/bash
if [ -z "$1" ]
then
echo "Please provide a domain name as argument"
exit 1
fi
DOMAIN=$1
IP=`dig +short A $DOMAIN`
/usr/local/psa/bin/dns -d ${DOMAIN} -a 'mail' -ip ${IP}
/usr/local/psa/bin/dns -d ${DOMAIN} -a 'webmail' -ip ${IP}
/usr/local/psa/bin/dns -d ${DOMAIN} -mx '' -mailexchanger mail.$1
/usr/local/psa/bin/dns -a ${DOMAIN} -cname 'mail' -canonical ghs.googlehosted.com.
/usr/local/psa/bin/dns -a ${DOMAIN} -cname 'webmail' -canonical ghs.googlehosted.com.
/usr/local/psa/bin/dns -a ${DOMAIN} -mx '' -mailexchanger ASPMX.L.GOOGLE.COM -priority 0
/usr/local/psa/bin/dns -a ${DOMAIN} -mx '' -mailexchanger ALT1.ASPMX.L.GOOGLE.COM. -priority 5
/usr/local/psa/bin/dns -a ${DOMAIN} -mx '' -mailexchanger ALT2.ASPMX.L.GOOGLE.COM. -priority 5
/usr/local/psa/bin/dns -a ${DOMAIN} -mx '' -mailexchanger ALT3.ASPMX.L.GOOGLE.COM. -priority 10
/usr/local/psa/bin/dns -a ${DOMAIN} -mx '' -mailexchanger ALT4.ASPMX.L.GOOGLE.COM. -priority 10
/usr/local/psa/bin/dns -d ${DOMAIN} -txt 'v=spf1 +a +mx -all'
/usr/local/psa/bin/dns -a ${DOMAIN} -txt 'v=spf1 include:_spf.google.com ~all'
/usr/local/psa/bin/dns --off ${DOMAIN}
/usr/local/psa/bin/dns --on ${DOMAIN}
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment