-# Copyright (C) 2004 Kalin Kozhuharov <kalin@ThinRope.net>
+# Copyright (C) 2004-2006 Kalin KOZHUHAROV <kalin@thinrope.net>
+# The latest version of this script can be accessed at:
+# rsync://rsync.tar.bz/gentoo-portage-pkalin/net-dns/djbdns/files/djbdns-setup
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
S_SEPARATOR="--------------------------------------------------------------------------------"
D_SEPARATOR="================================================================================"
S_SEPARATOR="--------------------------------------------------------------------------------"
D_SEPARATOR="================================================================================"
- ebegin "Adding user ${user}"
- /usr/sbin/useradd -d /dev/null -s /bin/false -g ${REQ_GROUP} ${user} &>/dev/null && eend 0 || eend 1
+ ebegin "Adding user ${user}"
+ /usr/sbin/useradd -d /dev/null -s /bin/false -g ${REQ_GROUP} ${user} &>/dev/null && eend 0 || eend 1
- local services="$1"
-
- echo "${SEPARATOR}"
- echo ": Start services :"
- echo
- echo " Your services (${services// /, }) are ready for startup!"
- echo
- ewarn " The following requires daemontools to be running!"
- local answer=""
- read -p " Would you like ${services// /, } to be started and supervised by daemontools now? [Y|n]> " answer
- if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
- then
+ local services="$1"
+
+ echo "${SEPARATOR}"
+ echo ": Start services :"
+ echo
+ echo " Your services (${services// /, }) are ready for startup!"
+ echo
+ ewarn " The following requires daemontools to be running!"
+ local answer=""
+ read -p " Would you like ${services// /, } to be started and supervised by daemontools now? [Y|n]> " answer
+ if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
+ then
echo
TCPRULES_DIR="${mypath}/axfrdns/${myip}/control"
echo " axfrdns is accessed by your secondary servers and when response cannot fit UDP packet"
echo
TCPRULES_DIR="${mypath}/axfrdns/${myip}/control"
echo " axfrdns is accessed by your secondary servers and when response cannot fit UDP packet"
sed -i -e "s#-x tcp.cdb#-x control/tcp.axfrdns.cdb#g" ${mypath}/axfrdns/${myip}/run
if [ -e ${TCPRULES_DIR}/tcp.axfrdns ]
then
sed -i -e "s#-x tcp.cdb#-x control/tcp.axfrdns.cdb#g" ${mypath}/axfrdns/${myip}/run
if [ -e ${TCPRULES_DIR}/tcp.axfrdns ]
then
- ewarn "${TCPRULES_DIR}/tcp.axfrdns exists."
- read -p " Do you want it cleared? [Y|n]: " answer
- if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
- then
+ ewarn "${TCPRULES_DIR}/tcp.axfrdns exists."
+ read -p " Do you want it cleared? [y|N]: " answer
+ if [ "${answer}" == "y" ]
+ then
- echo "${ipallow}:allow" >> ${TCPRULES_DIR}/tcp.axfrdns
- read -p " IP to allow (press Enter to end)> " ipallow
+ echo "${ipallow}:allow" >> ${TCPRULES_DIR}/tcp.axfrdns
+ read -p " IP to allow (press Enter to end)> " ipallow
read -p " Would you like ${TCPRULES_DIR}/tcp.axfrdns.cdb updated? [Y|n]: " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then
read -p " Would you like ${TCPRULES_DIR}/tcp.axfrdns.cdb updated? [Y|n]: " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then
- ebegin "Updating ${TCPRULES_DIR}/tcp.axfrdns.cdb"
- bash -c "cd ${TCPRULES_DIR} && make" && eend 0 || eend 1
+ ebegin "Updating ${TCPRULES_DIR}/tcp.axfrdns.cdb"
+ bash -c "cd ${TCPRULES_DIR} && make" && eend 0 || eend 1
- echo " dnscache can be configured to forward queries to another DNS cache"
- echo " (such as the one your ISP provides) rather than perform the lookups itself."
+ echo " dnscache can be configured to forward queries to another"
+ echo " DNS cache (such as the one your ISP provides) rather than"
+ echo " performing the lookups itself."
echo " provide the IPs of the caches to forward to."
echo " To have dnscache perform the lookups itself, just press Enter."
echo
echo " provide the IPs of the caches to forward to."
echo " To have dnscache perform the lookups itself, just press Enter."
echo
- echo $myforward > ${mypath}/dnscache/${myip}/root/servers/\@
- echo -n "1" > ${mypath}/dnscache/${myip}/env/FORWARDONLY
+ echo $myforward > ${mypath}/dnscache/${myip}/root/servers/\@
+ echo -n "1" > ${mypath}/dnscache/${myip}/env/FORWARDONLY
echo $myforward >> ${mypath}/dnscache/${myip}/root/servers/\@
read -p " forward-to IP (press Enter to end)> " myforward
echo $myforward >> ${mypath}/dnscache/${myip}/root/servers/\@
read -p " forward-to IP (press Enter to end)> " myforward
- echo
- echo " Currently all queries will be forwarded to:"
- echo
- cat ${mypath}/dnscache/${myip}/root/servers/\@
- echo
+ echo
+ echo " Currently all queries will be forwarded to:"
+ echo
+ cat ${mypath}/dnscache/${myip}/root/servers/\@
+ echo
- echo " By default dnscache allows only localhost (127.0.0.1) to access it."
- echo " You have to specify the IP addresses of the clients that shall be allowed to use it."
+ echo " By default dnscache allows only localhost (127.0.0.1) to"
+ echo " access it. You have to specify the IP addresses of the"
+ echo " clients that shall be allowed to use it."
- echo " 1.2.3.4 would allow only the host 1.2.3.4"
- echo " 1.2.3 would allow all hosts 1.2.3.x (like 1.2.3.4, 1.2.3.100, etc.)"
+ echo " 1.2.3.4 would allow only one host: 1.2.3.4"
+ echo " 1.2.3 would allow all hosts 1.2.3.0/24 (e.g. 1.2.3.4, 1.2.3.100, etc.)"
- touch ${mypath}/dnscache/${myip}/root/ip/${myclientip}
- read -p " Allowed IP (press Enter to end)> " myclientip
+ touch ${mypath}/dnscache/${myip}/root/ip/${myclientip}
+ read -p " Allowed IP (press Enter to end)> " myclientip
- done
-
- echo "${SEPARATOR}"
- echo ": IP address to bind to :"
- echo
- echo " Specify an address to which the ${service_human} should bind."
- echo " Currently accessible IPs:"
- local addrs=`ifconfig -a | grep "inet addr" | cut -f2 -d":" | cut -f1 -d" "`
- echo " "$addrs
- echo
-
- while [ "${myip}" == "" ]
- do
+ done
+
+ echo "${SEPARATOR}"
+ echo ": IP address to bind to :"
+ echo
+ echo " Specify an address to which the ${service_human} should bind."
+ echo " Currently accessible IPs:"
+ local addrs=`ifconfig -a | grep "inet addr" | cut -f2 -d":" | cut -f1 -d" "`
+ echo " "$addrs
+ echo
+
+ while [ "${myip}" == "" ]
+ do
- local dnscache_INSTALL="/usr/bin/dnscache-conf dnscache dnslog ${mypath}/dnscache/${myip} $myip"
- local tinydns_INSTALL="/usr/bin/tinydns-conf tinydns dnslog ${mypath}/tinydns/${myip} $myip"
- local axfrdns_INSTALL="\
+ local dnscache_INSTALL="/usr/bin/dnscache-conf dnscache dnslog ${mypath}/dnscache/${myip} $myip"
+ local tinydns_INSTALL="/usr/bin/tinydns-conf tinydns dnslog ${mypath}/tinydns/${myip} $myip"
+ local axfrdns_INSTALL="\
/usr/bin/axfrdns-conf tinydns dnslog ${mypath}/axfrdns/${myip} ${mypath}/tinydns/${myip} $myip &&\
mkdir -p ${mypath}/axfrdns/${myip}/control &&\
echo -e \"tcp.axfrdns.cdb:\ttcp.axfrdns\n\ttcprules tcp.axfrdns.cdb .tcp.axfrdns.cdb.tmp < tcp.axfrdns\" > ${mypath}/axfrdns/${myip}/control/Makefile &&\
rm -f ${mypath}/axfrdns/${myip}/tcp ${mypath}/axfrdns/${myip}/Makefile"
/usr/bin/axfrdns-conf tinydns dnslog ${mypath}/axfrdns/${myip} ${mypath}/tinydns/${myip} $myip &&\
mkdir -p ${mypath}/axfrdns/${myip}/control &&\
echo -e \"tcp.axfrdns.cdb:\ttcp.axfrdns\n\ttcprules tcp.axfrdns.cdb .tcp.axfrdns.cdb.tmp < tcp.axfrdns\" > ${mypath}/axfrdns/${myip}/control/Makefile &&\
rm -f ${mypath}/axfrdns/${myip}/tcp ${mypath}/axfrdns/${myip}/Makefile"
- ebegin "Setting up ${service} in ${mypath}/${service}/${myip}"
- eval command=\$${service}_INSTALL
- /bin/bash -c "${command}" && eend 0 || eend 1
+ ebegin "Setting up ${service} in ${mypath}/${service}/${myip}"
+ eval command=\$${service}_INSTALL
+ /bin/bash -c "${command}" && eend 0 || eend 1
- echo "${D_SEPARATOR}"
- echo ": DJB DNS setup :"
- echo
- echo " This script will help you setup the following:"
- echo
- echo " DNS server(s): to publish addresses of Internet hosts"
- echo
- echo " DNS cache(s) : to find addresses of Internet hosts"
- echo
- echo " For further information see:"
- echo " http://cr.yp.to/djbdns/blurb/overview.html"
- echo
- ewarn "If you have already setup your services,"
- ewarn "either exit now, or setup in different directories."
- echo
-
- answer=""
- read -p " Would you like to continue with setup? [Y|n]> " answer
- if [ "${answer}" == "n" ] || [ "${answer}" == "N" ]
- then
+ echo "${D_SEPARATOR}"
+ echo ": DJB DNS setup :"
+ echo
+ echo " This script will help you setup the following:"
+ echo
+ echo " DNS server(s): to publish addresses of Internet hosts"
+ echo
+ echo " DNS cache(s) : to find addresses of Internet hosts"
+ echo
+ echo " For further information see:"
+ echo " http://cr.yp.to/djbdns/blurb/overview.html"
+ echo
+ ewarn "If you have already setup your services,"
+ ewarn "either exit now, or setup in different directories."
+ echo
+
+ answer=""
+ read -p " Would you like to continue with setup? [Y|n]> " answer
+ if [ "${answer}" == "n" ] || [ "${answer}" == "N" ]
+ then
- fi
-
- echo "${D_SEPARATOR}"
- echo ": Choose install location :"
- echo
- default_path="/var"
- echo " The default (${default_path}) will install them"
- echo " in ${default_path}/\${service}/\${IP_ADDRESS}"
- echo
- echo " For example:"
- echo " /var/tinydns /1.2.3.4"
- echo " /192.168.33.1"
- echo " /axfrdns /1.2.3.4"
- echo " /192.168.33.1"
- echo " /dnscache/127.0.0.1"
- echo
- ewarn "Do NOT enter trailing slash"
- echo " Where do you want services installed?"
- read -p "[${default_path}] > " mypath
- echo
-
- if [ "${mypath}" == "" ]
- then
+ fi
+
+ echo "${D_SEPARATOR}"
+ echo ": Choose install location :"
+ echo
+ default_path="/var"
+ echo " The default (${default_path}) will install them"
+ echo " in ${default_path}/\${service}/\${IP_ADDRESS}"
+ echo
+ echo " For example:"
+ echo " /var/tinydns /1.2.3.4"
+ echo " /192.168.33.1"
+ echo " /axfrdns /1.2.3.4"
+ echo " /192.168.33.1"
+ echo " /dnscache/127.0.0.1"
+ echo
+ ewarn "Do NOT enter trailing slash"
+ echo " Where do you want services installed?"
+ read -p "[${default_path}] > " mypath
+ echo
+
+ if [ "${mypath}" == "" ]
+ then
echo "${D_SEPARATOR}"
answer=""
read -p " Would you like to setup ${another}dnscache? [Y|n]> " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then
echo "${D_SEPARATOR}"
answer=""
read -p " Would you like to setup ${another}dnscache? [Y|n]> " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then
echo "${D_SEPARATOR}"
answer=""
read -p " Would you like to setup ${another}DNS server? [Y|n]> " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then
echo "${D_SEPARATOR}"
answer=""
read -p " Would you like to setup ${another}DNS server? [Y|n]> " answer
if [ "${answer}" == "Y" ] || [ "${answer}" == "" ]
then