mirror of
https://github.com/AuxXxilium/docker-ddns-server.git
synced 2024-11-23 14:50:59 +07:00
add support for multiple domains in docker deployment
This commit is contained in:
parent
0993b7fdcb
commit
3dee004b2d
@ -5,7 +5,7 @@ services:
|
||||
restart: always
|
||||
environment:
|
||||
DDNS_ADMIN_LOGIN: 'admin:$$3$$abcdefg'
|
||||
DDNS_DOMAIN: 'dyndns.example.com'
|
||||
DDNS_DOMAINS: 'dyndns.example.com'
|
||||
DDNS_PARENT_NS: 'ns.example.com'
|
||||
DDNS_DEFAULT_TTL: '3600'
|
||||
ports:
|
||||
|
@ -1,4 +1,4 @@
|
||||
DDNS_ADMIN_LOGIN=admin:$$3$$abcdefg
|
||||
DDNS_DOMAIN=dyndns.example.com
|
||||
DDNS_DOMAINS=dyndns.example.com
|
||||
DDNS_PARENT_NS=ns.example.com
|
||||
DDNS_DEFAULT_TTL=3600
|
@ -1,33 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
[ -z "$DDNS_ADMIN_LOGIN" ] && echo "DDNS_ADMIN_LOGIN not set" && exit 1;
|
||||
[ -z "$DDNS_DOMAIN" ] && echo "DDNS_DOMAIN not set" && exit 1;
|
||||
[ -z "$DDNS_DOMAINS" ] && echo "DDNS_DOMAINS not set" && exit 1;
|
||||
[ -z "$DDNS_PARENT_NS" ] && echo "DDNS_PARENT_NS not set" && exit 1;
|
||||
[ -z "$DDNS_DEFAULT_TTL" ] && echo "DDNS_DEFAULT_TTL not set" && exit 1;
|
||||
|
||||
DDNS_IP=$(curl icanhazip.com)
|
||||
|
||||
if ! grep 'zone "'$DDNS_DOMAIN'"' /etc/bind/named.conf > /dev/null
|
||||
then
|
||||
echo "creating zone...";
|
||||
cat >> /etc/bind/named.conf <<EOF
|
||||
zone "$DDNS_DOMAIN" {
|
||||
for d in ${DDNS_DOMAINS//,/ }
|
||||
do
|
||||
if ! grep 'zone "'$d'"' /etc/bind/named.conf > /dev/null
|
||||
then
|
||||
echo "creating zone...";
|
||||
cat >> /etc/bind/named.conf <<EOF
|
||||
zone "$d" {
|
||||
type master;
|
||||
file "$DDNS_DOMAIN.zone";
|
||||
file "$d.zone";
|
||||
allow-query { any; };
|
||||
allow-transfer { none; };
|
||||
allow-update { localhost; };
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f /var/cache/bind/$DDNS_DOMAIN.zone ]
|
||||
then
|
||||
echo "creating zone file..."
|
||||
cat > /var/cache/bind/$DDNS_DOMAIN.zone <<EOF
|
||||
if [ ! -f /var/cache/bind/$d.zone ]
|
||||
then
|
||||
echo "creating zone file..."
|
||||
cat > /var/cache/bind/$d.zone <<EOF
|
||||
\$ORIGIN .
|
||||
\$TTL 86400 ; 1 day
|
||||
$DDNS_DOMAIN IN SOA ${DDNS_PARENT_NS}. root.${DDNS_DOMAIN}. (
|
||||
$d IN SOA ${DDNS_PARENT_NS}. root.${d}. (
|
||||
74 ; serial
|
||||
3600 ; refresh (1 hour)
|
||||
900 ; retry (15 minutes)
|
||||
@ -36,10 +38,11 @@ $DDNS_DOMAIN IN SOA ${DDNS_PARENT_NS}. root.${DDNS_DOMAIN}. (
|
||||
)
|
||||
NS ${DDNS_PARENT_NS}.
|
||||
A ${DDNS_IP}
|
||||
\$ORIGIN ${DDNS_DOMAIN}.
|
||||
\$ORIGIN ${d}.
|
||||
\$TTL ${DDNS_DEFAULT_TTL}
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# If /var/cache/bind is a volume, permissions are probably not ok
|
||||
chown root:bind /var/cache/bind
|
||||
|
Loading…
Reference in New Issue
Block a user