Changed pdns for test
This commit is contained in:
parent
9910cf40fd
commit
34f8426713
20
lib/pdns.sh
20
lib/pdns.sh
@ -105,9 +105,25 @@ start_pdns() {
|
||||
# Start service with command to make sure it's up before proceeding
|
||||
start_service "pdns" "nc -z ${SERVICE_IP} 8081 &> /dev/null"
|
||||
|
||||
# Create DNS records for newdomain
|
||||
docker exec -it pdns pdnsutil create-zone $DOMAIN
|
||||
docker exec -it pdns pdnsutil set-kind $DOMAIN native
|
||||
docker exec -it pdns pdnsutil set-meta $DOMAIN SOA-EDIT-API DEFAULT
|
||||
|
||||
for i in ns1 ns2 powerdns traefik mail www computer panel nextcloud collabora jitsi matrix element listmonk vaultwarden vpn wireguard baserow gitea blog documentation; do
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN $i A 86400 $EXTERNALIP
|
||||
done
|
||||
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN @ NS ns1.$DOMAIN_NEW
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN @ NS ns2.$DOMAIN_NEW
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN @ MX 86400 "10 mail.$DOMAIN"
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN @ TXT 86400 "\"v=spf1 mx a:$DOMAIN ~all\""
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN \* CNAME 86400 www.$DOMAIN
|
||||
docker exec -it pdns pdnsutil add-record $DOMAIN @ A 86400 $EXTERNALIP
|
||||
|
||||
# Run createrecords.sh inside baserow container
|
||||
docker exec -it pdns /root/createrecords.sh &> /dev/null
|
||||
[ $? -ne 0 ] && fail "Couldn't run createrecords.sh in /federated/apps/pdns container"
|
||||
# docker exec -it pdns /root/createrecords.sh &> /dev/null
|
||||
# [ $? -ne 0 ] && fail "Couldn't run createrecords.sh in /federated/apps/pdns container"
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
|
114
lib/pdns.sh.bak
Normal file
114
lib/pdns.sh.bak
Normal file
@ -0,0 +1,114 @@
|
||||
#!/bin/bash -x
|
||||
#
|
||||
# PowerDNS DNS Service
|
||||
|
||||
PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
config_pdns() {
|
||||
echo -ne "\n* Configuring /federated/apps/pdns container.."
|
||||
spin &
|
||||
SPINPID=$!
|
||||
|
||||
if [ ! -d "/federated/apps/pdns" ]; then
|
||||
mkdir -p /federated/apps/pdns/data/root
|
||||
fi
|
||||
|
||||
cat > /federated/apps/pdns/docker-compose.yml <<EOF
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
pdns:
|
||||
image: pschiffe/pdns-mysql:\${IMAGE_VERSION}
|
||||
container_name: pdns
|
||||
hostname: pdns.$DOMAIN
|
||||
domainname: $DOMAIN
|
||||
restart: always
|
||||
networks:
|
||||
federated:
|
||||
ipv4_address: 172.99.0.11
|
||||
ports:
|
||||
- "53:53"
|
||||
- "53:53/udp"
|
||||
env_file:
|
||||
- ./.env
|
||||
volumes:
|
||||
- ./data/root:/root
|
||||
|
||||
networks:
|
||||
federated:
|
||||
external: true
|
||||
EOF
|
||||
|
||||
MYSQL_PASSWORD=`grep MYSQL_PASSWORD /federated/apps/pdnsmysql/.env | awk -F= '{ print $2 }'`
|
||||
PDNS_APIKEY=$(create_password);
|
||||
PDNS_WEBSERVER_PASSWORD=$(create_password);
|
||||
|
||||
cat > /federated/apps/pdns/.env <<EOF
|
||||
IMAGE_VERSION="4.7"
|
||||
PDNS_gmysql_host=pdnsmysql.$DOMAIN
|
||||
PDNS_gmysql_port=3306
|
||||
PDNS_gmysql_user=pdns
|
||||
PDNS_gmysql_dbname=pdns
|
||||
PDNS_gmysql_password=$MYSQL_PASSWORD
|
||||
PDNS_master=yes
|
||||
PDNS_api=yes
|
||||
PDNS_api_key=$PDNS_APIKEY
|
||||
PDNSCONF_API_KEY=$PDNS_APIKEY
|
||||
PDNS_webserver=yes
|
||||
PDNS_webserver-allow-from=127.0.0.1,10.0.0.0/8,172.0.0.0/8,192.0.0.0/24,172.99.0.0/16
|
||||
PDNS_webserver_address=0.0.0.0
|
||||
PDNS_webserver_password=$PDNS_WEBSERVER_PASSWORD
|
||||
PDNS_version_string=anonymous
|
||||
PDNS_default_ttl=1500
|
||||
PDNS_allow_notify_from=0.0.0.0
|
||||
PDNS_allow_axfr_ips=127.0.0.1
|
||||
PDNS_default_soa_content=ns1.@ hostmaster.@ 0 10800 3600 604800 3600
|
||||
PDNS_allow_dnsupdate_from=127.0.0.0/8,::1,172.99.0.0/16
|
||||
PDNS_dnsupdate=yes
|
||||
EOF
|
||||
chmod 600 /federated/apps/pdns/.env
|
||||
|
||||
cat > /federated/apps/pdns/data/root/createrecords.sh <<EOF
|
||||
#!/bin/bash -x
|
||||
|
||||
# Create the default domain DNS zone
|
||||
curl -X POST --data '{"name":"$DOMAIN.", "kind": "Master", "masters": []}' -v -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones
|
||||
|
||||
# Create the MX and SPF TXT record for domain
|
||||
curl -X PATCH --data '{"rrsets": [ {"name": "$DOMAIN.", "type": "MX", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "10 mail.$DOMAIN.", "disabled": false } ] } ] }' -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
|
||||
curl -X PATCH --data '{"rrsets": [ {"name": "$DOMAIN.", "type": "TXT", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "\"v=spf1 mx a:$DOMAIN ~all\"", "disabled": false } ] } ] }' -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
|
||||
|
||||
# Create the A records for domain
|
||||
for i in ns1 ns2 pdnsadmin powerdns traefik mail www computer panel nextcloud collabora jitsi matrix element listmonk vaultwarden vpn wireguard baserow gitea blog documentation; do
|
||||
curl -X PATCH --data "{\"rrsets\": [ {\"name\": \"\$i.$DOMAIN.\", \"type\": \"A\", \"ttl\": 86400, \"changetype\": \"REPLACE\", \"records\": [ {\"content\": \"$EXTERNALIP\", \"disabled\": false } ] } ] }" -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
|
||||
done
|
||||
|
||||
# TEST
|
||||
|
||||
# Create catchall A record for domain
|
||||
#curl -X PATCH --data '{"rrsets": [ {"name": "*.$DOMAIN.", "type": "A", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "$EXTERNALIP", "disabled": false } ] } ] }' -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
|
||||
|
||||
# Create CNAME record for domain to www
|
||||
curl -X PATCH --data '{"rrsets": [ {"name": "*.$DOMAIN.", "type": "CNAME", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "www.$DOMAIN.", "disabled": false } ] } ] }' -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
|
||||
|
||||
pdnsutil add-record $DOMAIN @ A 86400 $EXTERNALIP
|
||||
EOF
|
||||
chmod +x /federated/apps/pdns/data/root/createrecords.sh
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
}
|
||||
start_pdns() {
|
||||
# Grab the container IP from docker-compose above
|
||||
SERVICE_IP=`grep ipv4_address /federated/apps/pdns/docker-compose.yml | awk '{ print $2 }'`
|
||||
|
||||
# Start service with command to make sure it's up before proceeding
|
||||
start_service "pdns" "nc -z ${SERVICE_IP} 8081 &> /dev/null"
|
||||
|
||||
# Run createrecords.sh inside baserow container
|
||||
docker exec -it pdns /root/createrecords.sh &> /dev/null
|
||||
[ $? -ne 0 ] && fail "Couldn't run createrecords.sh in /federated/apps/pdns container"
|
||||
|
||||
kill -9 $SPINPID &> /dev/null
|
||||
echo -ne "done."
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user