mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-08-22 19:20:24 +00:00
84 lines
2.3 KiB
Bash
Executable File
84 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# is_lsb_ubuntu exit status indicates whether system appears to be Ubuntu.
|
|
# Using required /etc/lsb-release file, instead of optional lsb_release command.
|
|
|
|
is_lsb_ubuntu ()
|
|
{
|
|
awk '
|
|
(match($0, "^[ \t]*DISTRIB_ID=") == 1) { # A DISTRIB_ID line
|
|
id = substr($0, RLENGTH + 1) # Save its value
|
|
}
|
|
|
|
END {
|
|
# Examine last DISTRIB_ID value to see if Ubuntu indicated
|
|
|
|
if (match(id, "^(Ubuntu|\"Ubuntu\")[ \t]*$") == 1) {
|
|
exit 0 # Ubuntu
|
|
}
|
|
exit 1 # Not Ubuntu
|
|
}
|
|
|
|
' /etc/lsb-release >/dev/null 2>&1
|
|
|
|
# Routine exit status is exit status of the last command -- the awk script.
|
|
#
|
|
# Note: if /etc/lsb-release does not exist, the exit status indicates
|
|
# failure (not Ubuntu), which is the correct outcome.
|
|
}
|
|
|
|
|
|
DIRECTORY=/var/named
|
|
|
|
# check for SLES
|
|
grep -s -q sles /etc/os-release
|
|
IS_SLES=$?
|
|
if [ -f /etc/SuSE-release ] || [ $IS_SLES -eq 0 ]; then
|
|
DIRECTORY=/var/lib/named
|
|
fi
|
|
FILE=/etc/named.conf
|
|
|
|
if ( is_lsb_ubuntu ); then
|
|
FILE=/etc/bind/named.conf
|
|
fi
|
|
|
|
#unalias cp
|
|
if [ -f $FILE ]; then
|
|
cp -f $FILE ${FILE}.ORIG
|
|
fi
|
|
if [ ! -d $DIRECTORY ]; then
|
|
mkdir $DIRECTORY
|
|
fi
|
|
echo "options {
|
|
directory \"$DIRECTORY\";
|
|
dump-file \"$DIRECTORY/data/cache_dump.db\";
|
|
statistics-file \"$DIRECTORY/data/named_stats.txt\";
|
|
memstatistics-file \"$DIRECTORY/data/named_mem_stats.txt\";
|
|
recursion yes;
|
|
forward only;
|
|
forwarders {" >$FILE
|
|
|
|
for i in $(grep "^nameserver" /etc/resolv.conf | awk '{print $2}')
|
|
do
|
|
echo " $i;"
|
|
done >>$FILE
|
|
echo " };" >>$FILE
|
|
|
|
# Natural version compare against version of bind.
|
|
# If version 9.16.6 or higher, turn off DNSSEC
|
|
BIND_VERSION=$(/usr/sbin/named -v | cut -d" " -f2 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
|
|
CONTROL_BIND_VERSION="9.16.6"
|
|
|
|
# "sort --version-sort" takes lines of version strings and sorts them.
|
|
# Output is lines of versions in sorted order, last line is highest version number
|
|
LAST_IN_COMPARE=`printf '%s\n' $BIND_VERSION $CONTROL_BIND_VERSION | sort --version-sort | tail -n1`
|
|
|
|
if [ $BIND_VERSION = $LAST_IN_COMPARE ]; then
|
|
# current version of BIND was last in sorted order,
|
|
# therefor it is higher than CONTROL_BIND_VERSION
|
|
echo " dnssec-enable no;
|
|
dnssec-validation no;" >>$FILE
|
|
fi
|
|
echo "};" >>$FILE
|
|
|