-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.sh
84 lines (68 loc) · 1.71 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
if [[ -z "${BIND9_ROOTDOMAIN}" ]];then
echo "The variable BIND9_ROOTDOMAIN must be set"
exit 1
fi
if [[ -z "${API_USER}" ]];then
echo "The variable API_USER must be set"
exit 1
fi
if [[ -z "${API_PASSWORD}" ]];then
echo "The variable API_PASSWORD must be set"
exit 1
fi
if [[ -z "${DYNDNS_TTL}" ]];then
echo "The variable DYNDNS_TTL must be set"
exit 1
fi
if [[ -z "${DYNDNS_DOMAINS}" ]];then
echo "The variable DYNDNS_DOMAINS must be set"
exit 1
fi
echo "Creating local named configuration"
cat <<EOF > /etc/bind/named.conf.local
zone "${BIND9_ROOTDOMAIN}" {
type master;
file "/var/cache/bind/${BIND9_ROOTDOMAIN}.zone";
allow-query { any; };
allow-transfer { none; };
allow-update { localhost; };
};
EOF
echo "Creating ${BIND9_ROOTDOMAIN} configuration"
cat <<EOF > /var/cache/bind/${BIND9_ROOTDOMAIN}.zone
${BIND9_ROOTDOMAIN}. IN SOA localhost. root.localhost. (
74 ; serial
3600 ; refresh (1 hour)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS localhost.
EOF
echo "Creating named options configuration"
cat <<EOF > "/etc/bind/named.conf.options"
options {
directory "/var/cache/bind";
recursion no;
dnssec-validation auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
allow-transfer { none; };
};
EOF
echo "Creating dyndns api config"
cat > /root/dyndnsConfig.json <<EOF
{
"User": "${API_USER}",
"Password": "${API_PASSWORD}",
"Zone": "${BIND9_ROOTDOMAIN}",
"Domains": ${DYNDNS_DOMAINS},
"TTL": "${DYNDNS_TTL}"
}
EOF
mkdir -p /var/cache/bind
chown root:bind /var/cache/bind
chmod 770 /var/cache/bind
service bind9 restart
/root/dyndns-api