#! /bin/bash #----------------------------------------------------------------------------- # /usr/libexec/bind/named.prep - BIND 9 start script # # Creation: 2023-06-22 hbfl # Last Update: $Id$ # # Copyright (c) 2014-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #----------------------------------------------------------------------------- . /etc/config.d/bind9 #include eisdate-time . /var/install/include/eistime bind_root='/var/lib/named' s_search='' rc=0 warnMessage() { logger "Warning: $1" } # ---------------------------------------------------------------------------- # update resolf file # ---------------------------------------------------------------------------- write_resolv_file() { echo 'DO NOT REMOVE ME IF BIND RUNNING' > /etc/sysconfig/network/forwarder/bind /usr/sbin/service ${quiet} restart resolver.service # # . /etc/config.d/base # if [ -z "${s_search}" ] # then # s_search="${DOMAIN_NAME}" # fi # { # echo "# --------------------------------------------------------------------------" # echo "# /etc/resolv.conf" # echo "# Last Update: ${EISDATE} ${EISTIME} by /var/install/config.d/bind9" # echo "# --------------------------------------------------------------------------" # echo "search ${s_search} " # echo "nameserver 127.0.0.1 " # idx=1 # for dns_server in ${DNS_SERVER} # do # if [ ${idx} -le 2 ] # then # if [ ! "${dns_server}" = "127.0.0.1" ] # then # echo "nameserver ${dns_server} " # fi # fi # idx=$((${idx} + 1)) # done # echo # } >/etc/resolv.conf } # --------------------------------------------------------------------------- # check all master zone files # --------------------------------------------------------------------------- check_zone_files() { idx=1 while [ ${idx} -le ${BIND9_N} ] do eval zone_name='${BIND9_'${idx}'_NAME}' eval zone_mast='${BIND9_'${idx}'_MASTER}' s_search="${s_search} ${zone_name}" if [ "${zone_mast}" = 'yes' ] then /usr/bin/named-checkzone -q -t ${bind_root}/etc/bind/master ${zone_name} ${zone_name}.zone >/dev/null if [ ${?} -eq 1 ] then # echo_ok echo echo "Configuration error zone ${zone_name}" /usr/bin/named-checkzone -t ${bind_root}/etc/bind/master ${zone_name} ${zone_name}.zone sleep 3 exit 1 fi fi idx=$((${idx} + 1)) done } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- # create named.conf.local named_files=$(/usr/bin/find ${bind_root}/etc/bind/include -maxdepth 1 -type f -name '*' -printf '%f\n') /usr/bin/rm -f ${bind_root}/etc/bind/named.conf.local for i in ${named_files} do echo "include \"/etc/bind/include/${i}\";" >> ${bind_root}/etc/bind/named.conf.local done /usr/bin/chown named:named ${bind_root}/etc/bind/named.conf.local /usr/bin/chmod 0644 ${bind_root}/etc/bind/named.conf.local # check all zone files check_zone_files # write resolv file # write_resolv_file # copy ssl engines into chroot # if [ "$(arch)" = "x86_64" ] # then # lib_dir=64 # fi # /usr/bin/cp -f /usr/lib${lib_dir}/engines-3/* ${bind_root}/usr/lib/engines-3/ # Make sure /etc/named.d/forwarders.conf exists #[ -e /etc/named.d/forwarders.conf ] || touch /etc/named.d/forwarders.conf # Check the syntax of our 'named' configuration. if ! /usr/bin/named-checkconf -t ${bind_root} >/dev/null; then [ $rc != 0 ] || rc=6 fi exit $rc