Setting Up PowerDNS Part 1

#!/bin/bash
# Install PowerDNS and PowerDNS Admin web GUI

ROOT_MYSQL_PASSWORD="penguin"
POWER_DNS_MYSQL_PASSWORD="penguin"
POWERDNS_VERSION="3.8.1"
URL_FOR_POWERDNS="https://codeload.github.com/poweradmin/poweradmin/tar.gz/refs/tags/v$POWERDNS_VERSION"
domain_name="tuxmail.io"
wireguard_static_ip=94.158.244.150
time_zone="America/New_York"
zone_info="US/Eastern"

# Set a time zone

DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
ln -fs /usr/share/zoneinfo/$zone_info /etc/localtime
echo "$time_zone" > /etc/timezone

# Systemd's resolver interferes with PowerDNS so disable it

systemctl stop systemd-resolved
systemctl disable systemd-resolved

# make sure nameserver 127.0.0.1 and 9.9.9.9 gets added to /etc/resolv.conf

echo "supersede domain-name-servers 9.9.9.9, 127.0.0.1;" > /etc/dhcp/dhclient.conf

echo nameserver 9.9.9.9 >> /etc/resolvconf/resolv.conf.d/head
echo nameserver 127.0.0.1 >> /etc/resolvconf/resolv.conf.d/head

# apply changes so /etc/resolv.conf gets updated
resolvconf -u

# Install mysql if not installed

apt update
apt install apache2 mariadb-server -y

# Secure mysql

#script -q -c 'mysql_secure_installation' < "/etc/apache2/sites-enabled/powerdns.conf"

ServerName powerdns.$domain_name
DocumentRoot /var/www/powerdns

Options FollowSymLinks
AllowOverride All

Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

EOF

# Restart apache2

systemctl restart apache2