/
v-list-sys-dns-status
executable file
·75 lines (63 loc) · 2.16 KB
/
v-list-sys-dns-status
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
#!/bin/bash
# info: list dns status
# options: [FORMAT]
#
# The function lists dns server status
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
#format=${1-shell}
# Includes
#source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking dns system
if [ -z "$DNS_SYSTEM" ]; then
exit
fi
# Checking statistics-file on RHEL/CentOS
if [ -e "/etc/named/named.conf" ]; then
conf="/etc/named/named.conf"
dump_file='/var/named/data/named_stats.txt'
dump_option=" dump-file \"$dump_file\";"
opt_check=$(grep $dump_file $conf |grep -v //)
if [ -z "$opt_check" ]; then
sed -i "s|options {|options {\n$dump_option|" $conf
service named restart >/dev/null 2>&1
fi
fi
if [ -e "/etc/named.conf" ]; then
conf="/etc/named.conf"
dump_file='/var/named/data/named_stats.txt'
dump_option=" dump-file \"$dump_file\";"
opt_check=$(grep $dump_file $conf |grep -v //)
if [ -z "$opt_check" ]; then
sed -i "s|options {|options {\n$dump_option|" $conf
service named restart >/dev/null 2>&1
fi
fi
# Checking statistics-file on Debian/Ubuntu
if [ -e "/etc/bind/named.conf" ]; then
conf="/etc/bind/named.conf.options"
dump_file='/var/cache/bind/named.stats'
#dump_option=" dump-file \"$dump_file\";"
#opt_check=$(grep $dump_file $conf |grep -v //)
#if [ -z "$opt_check" ]; then
# sed -i "s|options {|options {\n$dump_option|" $conf
# service named restart >/dev/null 2>&1
#fi
fi
# Generating dns stats
rm -f $dump_file 2>/dev/null
/usr/sbin/rndc stats 2>/dev/null
# Displaying dns status
if [ -e "$dump_file" ]; then
cat $dump_file
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit