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