# this script will do everything but transfer emails from an old domain

# check for root
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

source email_dns_vars.txt

#make sure vars not empty
if [[ -z $DOMAIN || -z $MAILSERVER || -z $MAILCOWAPIKEY || -z $DNS_CLOUDFLARE_API_KEY || -z $EMAILLOCALPART || -z $FULLNAME || -z $EMAILPASSWORD ]]; then
  echo 'one or more variables are undefined in email_vars.txt, please populate and try again...'
  exit 1
fi

bash email/create_email_domain.sh
bash email/create_email_dns_records.sh
bash email/create_mailbox.sh