From f1d6b8a9d3c06f74e904959887cf043d09aff687 Mon Sep 17 00:00:00 2001 From: Dexter Morgan Date: Thu, 2 Jun 2011 20:51:50 +0000 Subject: Branch for updates --- dns_wizard/scripts/do_it_dns.sh | 177 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100755 dns_wizard/scripts/do_it_dns.sh (limited to 'dns_wizard/scripts/do_it_dns.sh') diff --git a/dns_wizard/scripts/do_it_dns.sh b/dns_wizard/scripts/do_it_dns.sh new file mode 100755 index 00000000..84807609 --- /dev/null +++ b/dns_wizard/scripts/do_it_dns.sh @@ -0,0 +1,177 @@ +#!/bin/bash +# +# Wizard +# +# Copyright (C) 2000 Mandrakesoft. +# +# 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. +# See file LICENSE for further informations on licensing terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Authors: Jerome Dumonteil, Maurizio De Cecco, Enzo Maggi +# icons: Helene Durosini +# http://www.mandrakesoft.com + +# script for wizard dns configuration +# +# install default dns configuration for server +# assuming all dependencies are ok + +wiz_ip_net=`get_var wiz_ip_net` +wiz_ip_server=`get_var wiz_ip_server` +wiz_domain_name=`get_var wiz_domain_name` +wiz_host_name=`get_var wiz_host_name` +s_trunc=${wiz_ip_net%.*} +ds=${wiz_ip_server##*.} +host=${wiz_host_name%%.*} + + +# change serial number +# $1 : file +up_serial(){ +TMPFILE=`mktemp /tmp/temp.XXXXXX` || exit 1 +cat $1 > ${TMPFILE} +serial_nbm=$(date "+%Y%m%d00") +serial_f=`sed -ne "s/^\([[:space:]]*\)\([0-9]*\)\([[:space:]]*;[[:space:]]*Serial.*$\)/\2/p" ${TMPFILE}` +serial_f=$((${serial_f}+1)) +if [ ${serial_f} -le ${serial_nbm} ]; then + serial_f=${serial_nbm} +fi + +cat ${TMPFILE}\ +|sed -e "s/^\([[:space:]]*\)\([0-9]*\)\([[:space:]]*;[[:space:]]*Serial.*$\)/\1${serial_f}\3/"\ +> $1 +rm -f ${TMPFILE} +} + + + + + + + +# host.conf +bck_file /etc/host.conf +cat ${CWD}/scripts/host.conf.default > /etc/host.conf + +# named.conf +file=/etc/named.conf +bck_file ${file} + +echo_debug "now putting ${file} configuration" + +reversenet=`echo ${wiz_ip_net}|sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.[0-9]*$/\3\.\2\.\1/'` +echo_debug "reversenet : ${reversenet}" + +cat ${CWD}/scripts/named.conf.default > /var/tmp/named.conf.default + +if [ -z "${wiz_ext_dns1}" ]; then + TMPFILE=`mktemp /tmp/temp.XXXXXX` || exit 1 + cat /var/tmp/named.conf.default > ${TMPFILE} + cat ${TMPFILE}|sed -e "s/^.*__ISPNS1__.*$/\/\/&/" >/var/tmp/named.conf.default + rm -f ${TMPFILE} +fi +if [ -z "${wiz_ext_dns2}" ]; then + TMPFILE=`mktemp /tmp/temp.XXXXXX` || exit 1 + cat /var/tmp/named.conf.default > ${TMPFILE} + cat ${TMPFILE}|sed -e "s/^.*__ISPNS2__.*$/\/\/&/" >/var/tmp/named.conf.default + rm -f ${TMPFILE} +fi + +cat /var/tmp/named.conf.default \ +|sed "s|__ISPNS1__|${wiz_ext_dns1}|g" \ +|sed "s|__ISPNS2__|${wiz_ext_dns2}|g" \ +|sed "s|__dname__|${wiz_domain_name}|g" \ +|sed "s|__revnet__|${reversenet}|g" \ +|sed "s|__net__|${s_trunc}|g" \ +> ${file} + +# Bug fix for bind 9: +touch /etc/rndc.key + +# root.hints +file=/var/named/root.hints +bck_file ${file} + +cat ${CWD}/scripts/root.hints.default > ${file} + +# 127.0.0.rev +file=/var/named/127.0.0.rev +bck_file ${file} + +cat ${CWD}/scripts/127.0.0.rev.default \ +|sed "s|__hname__|${wiz_host_name}|g" \ +> ${file} + +up_serial ${file} + +# ipnet.rev + +file=/var/named/${s_trunc}.rev +echo_debug "config about ${file}" +bck_file ${file} + +cat ${CWD}/scripts/ipnet.rev.default > /var/tmp/ipnet.rev.default + +cat /var/tmp/ipnet.rev.default \ +|sed "s|__dname__|${wiz_domain_name}|g" \ +|sed "s|__hname__|${wiz_host_name}|g" \ +|sed "s|__revnet__|${reversenet}|g" \ +|sed "s|__nb__|${ds}|g" \ +> ${file} + +up_serial ${file} + +# domain.db +file=/var/named/${wiz_domain_name}.db +bck_file ${file} +echo_debug "config ${file}" + +cat ${CWD}/scripts/domain.db.default > /var/tmp/domain.db.default + +cat /var/tmp/domain.db.default \ +|sed "s|__dname__|${wiz_domain_name}|g" \ +|sed "s|__hname__|${wiz_host_name}|g" \ +|sed "s|__ip__|${wiz_ip_server}|g" \ +|sed "s|__host__|${host}|g" \ +> ${file} + +up_serial ${file} + +# resolv.conf +file=/etc/resolv.conf +bck_file ${file} +echo_debug "config ${file}" + +echo -e "\ +domain ${wiz_domain_name}\n\ +nameserver ${wiz_ip_server}\n\ +" > ${file} + + + + +# restarting bind +/sbin/chkconfig --level 235 named on +/etc/rc.d/init.d/named restart + + +file=/etc/sysconfig/mdk_serv +wiz_caching_dns="1" +chg_val ${file} wiz_caching_dns ${wiz_caching_dns} s +# all is ok +exit 10 + + + -- cgit v1.2.1