|
| 1 | +#!/bin/bash |
| 2 | +# info: list dns status |
| 3 | +# options: [FORMAT] |
| 4 | +# |
| 5 | +# The function lists dns server status |
| 6 | + |
| 7 | + |
| 8 | +#----------------------------------------------------------# |
| 9 | +# Variable&Function # |
| 10 | +#----------------------------------------------------------# |
| 11 | + |
| 12 | +# Argument defenition |
| 13 | +#format=${1-shell} |
| 14 | + |
| 15 | +# Includes |
| 16 | +#source $VESTA/func/main.sh |
| 17 | +source $VESTA/conf/vesta.conf |
| 18 | + |
| 19 | +#----------------------------------------------------------# |
| 20 | +# Action # |
| 21 | +#----------------------------------------------------------# |
| 22 | + |
| 23 | +# Checking dns system |
| 24 | +if [ -z "$DNS_SYSTEM" ]; then |
| 25 | + exit |
| 26 | +fi |
| 27 | + |
| 28 | +# Checking statistics-file on RHEL/CentOS |
| 29 | +if [ -e "/etc/named/named.conf" ]; then |
| 30 | + conf="/etc/named/named.conf" |
| 31 | + dump_file='/var/named/data/named_stats.txt' |
| 32 | + dump_option=" dump-file \"$dump_file\";" |
| 33 | + opt_check=$(grep $dump_file $conf |grep -v //) |
| 34 | + if [ -z "$opt_check" ]; then |
| 35 | + sed -i "s|options {|options {\n$dump_option|" $conf |
| 36 | + service named restart >/dev/null 2>&1 |
| 37 | + fi |
| 38 | +fi |
| 39 | +if [ -e "/etc/named.conf" ]; then |
| 40 | + conf="/etc/named.conf" |
| 41 | + dump_file='/var/named/data/named_stats.txt' |
| 42 | + dump_option=" dump-file \"$dump_file\";" |
| 43 | + opt_check=$(grep $dump_file $conf |grep -v //) |
| 44 | + if [ -z "$opt_check" ]; then |
| 45 | + sed -i "s|options {|options {\n$dump_option|" $conf |
| 46 | + service named restart >/dev/null 2>&1 |
| 47 | + fi |
| 48 | +fi |
| 49 | + |
| 50 | +# Checking statistics-file on Debian/Ubuntu |
| 51 | +if [ -e "/etc/bind/named.conf" ]; then |
| 52 | + conf="/etc/bind/named.conf.options" |
| 53 | + dump_file='/var/cache/bind/named.stats' |
| 54 | + #dump_option=" dump-file \"$dump_file\";" |
| 55 | + #opt_check=$(grep $dump_file $conf |grep -v //) |
| 56 | + #if [ -z "$opt_check" ]; then |
| 57 | + # sed -i "s|options {|options {\n$dump_option|" $conf |
| 58 | + # service named restart >/dev/null 2>&1 |
| 59 | + #fi |
| 60 | +fi |
| 61 | + |
| 62 | +# Generating dns stats |
| 63 | +rm -f $dump_file 2>/dev/null |
| 64 | +/usr/sbin/rndc stats 2>/dev/null |
| 65 | + |
| 66 | +# Displaying dns status |
| 67 | +if [ -e "$dump_file" ]; then |
| 68 | + cat $dump_file |
| 69 | +fi |
| 70 | + |
| 71 | +#----------------------------------------------------------# |
| 72 | +# Vesta # |
| 73 | +#----------------------------------------------------------# |
| 74 | + |
| 75 | +exit |
0 commit comments