-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·39 lines (32 loc) · 1.19 KB
/
test.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
#!/bin/bash
CONTAINER_NAME=$(uuidgen)
docker run -e ZONES="example.com" -e REVERSE_ZONES="0.168.192" --name="$CONTAINER_NAME" -d -t mycloudlab/infra-dynamic-dns
while [ $(docker logs $CONTAINER_NAME |grep 'Start named' | wc -l) -eq 0 ] ; do echo 'wait start bind...'; sleep 1; done
function cleanup_and_exit() {
docker rm -f $CONTAINER_NAME
docker image prune -f
exit 1;
}
echo "
server localhost
zone example.com
update del test.example.com. A
update add test.example.com 1440 A 192.168.0.1
zone 0.168.192.in-addr.arpa
update del 1.0.168.192.in-addr.arpa. PTR
update add 1.0.168.192.in-addr.arpa. 300 PTR test.example.com
show
send
" | docker exec -i $CONTAINER_NAME nsupdate
if [ "$(docker exec -i $CONTAINER_NAME dig @localhost test.example.com +short)" == "192.168.0.1" ]; then
echo [ok] - dns created with success
else
echo [fail] - dns test.example.com does not created
cleanup_and_exit
fi
if [ "$(docker exec -i $CONTAINER_NAME dig @localhost -x 192.168.0.1 +short)" == "test.example.com." ]; then
echo [ok] - reverse dns created with success
else
echo [fail] - reverse dns for 192.168.0.1 does not pointer to test.example.com not created
cleanup_and_exit
fi