Created
September 14, 2023 23:45
-
-
Save tuna2134/1ee2727dc0406042ec28414f3901a763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /bin/bash | |
echo "MySQL hostname if you want to build at localhost please send localhost" | |
read MYSQL_HOST | |
echo "MySQL user" | |
read MYSQL_USER | |
echo "MySQL password" | |
read MYSQL_PASSWORD | |
echo "MySQL Database" | |
read MYSQL_DATABASE | |
dnf update -y | |
dnf install -y epel-release | |
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash | |
dnf install -y pdns pdns-backend-mysql pdns-tools mariadb | |
if [ $MYSQL_HOST = "localhost" ]; then | |
dnf install -y mariadb-server | |
systemctl enable --now mariadb | |
systemctl start mariadb | |
cat <<EOF > ./user.sql | |
CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD'; | |
GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'localhost' WITH GRANT OPTION; | |
CREATE DATABASE $MYSQL_DATABASE; | |
EOF | |
mariadb -u root < ./user.sql | |
fi | |
echo $MYSQL_HOST | |
cat <<EOF > /etc/pdns/pdns.conf | |
version-string=anonymous | |
server-id=disabled | |
launch=gmysql:dns | |
gmysql-dns-host=$MYSQL_HOST | |
gmysql-dns-dbname=$MYSQL_DATABASE | |
gmysql-dns-user=$MYSQL_USER | |
gmysql-dns-password=$MYSQL_PASSWORD | |
gmysql-dns-dnssec=yes | |
EOF | |
mariadb -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < /usr/share/doc/pdns/schema.mysql.sql | |
setenforce 0 | |
systemctl start pdns | |
systemctl enable pdns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Required RHEL8+