X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=net-dns%2Fdjbdns%2Ffiles%2Ftinydns-setup;fp=net-dns%2Fdjbdns%2Ffiles%2Ftinydns-setup;h=ed92a136c1a95097bf351066a6a29ae0c25eaa6a;hb=1e83906f94688c95f6f8ad6f33896df3330a9e01;hp=0000000000000000000000000000000000000000;hpb=c2d8376688dad2c42c9c8f4a6e96629ef328f48d;p=mjo-overlay.git diff --git a/net-dns/djbdns/files/tinydns-setup b/net-dns/djbdns/files/tinydns-setup new file mode 100644 index 0000000..ed92a13 --- /dev/null +++ b/net-dns/djbdns/files/tinydns-setup @@ -0,0 +1,151 @@ +#!/bin/bash + +# +# source functions.sh for einfo, eerror and ewarn +. /etc/init.d/functions.sh + +setup() { + echo + echo + einfo "tinydns Setup" + echo + echo ">>> More information on this package can be found at" + echo ">>> http://cr.yp.to/djbdns/tinydns.html" + echo + echo "If you have previously setup tinydns, those directories will" + echo "not be overwritten. To redo setup, delete your" + echo "tinydns dir tree first." + echo + echo '(press enter to begin setup, or press control-C to abort)' + echo + read + + echo + einfo "Install location" + echo + echo "Where do you want tinydns installed?" + echo "Ex. /var would install dnscache in /var/tinydns." + echo "!!No trailing slash!!" + echo + read -p "[/var]> " mypath + echo + + if [ "$mypath" == "" ] + then + mypath="/var" + fi + + if [ ! -e ${mypath} ] + then + echo ">>> Creating ${mypath}..." + mkdir $mypath + fi + + # check for existance of users tinydns and dnslog: + echo + echo + einfo "Checking for tinydns and dnslog user accts ..." + echo + /usr/bin/grep nofiles /etc/group &> /dev/null + if [ $? -ne 0 ] + then + echo ">>> Adding group nofiles ..." + /usr/sbin/groupadd nofiles &> /dev/null + fi + + /usr/bin/grep tinydns /etc/passwd &> /dev/null + if [ $? -ne 0 ] + then + echo ">>> Adding user tinydns ..." + /usr/sbin/useradd -d /dev/null -s /bin/false -g nofiles \ + tinydns &> /dev/null + fi + + /usr/bin/grep dnslog /etc/passwd &> /dev/null + if [ $? -ne 0 ] + then + echo ">>> Adding user dnslog ..." + /usr/sbin/useradd -d /dev/null -s /bin/false -g nofiles \ + dnslog &> /dev/null + fi + + + # grab interfaces + addrs=`ifconfig -a | grep "inet addr" | cut -f2 -d":" | cut -f1 -d" "` + + echo "Specify an address to which tinydns should bind." + echo "NOTICE: tinydns must be able to bind to port 53 on " + echo "choosen ip address! udp by tinydns - tcp by axfrdns" + echo "Usually this is NOT 127.0.0.1" + echo "Currently running IP addresses:" + echo + echo $addrs + echo + + while [ "$myip" = "" ] + do + read -p "IP to bind nameserver to>" myip + done + echo + + if [ ! -e ${mypath}/tinydns ] + then + einfo "Setting up tinydns..." + /usr/bin/tinydns-conf tinydns dnslog \ + ${mypath}/tinydns $myip + else + ewarn "*** tinydns directory currently exists, nothing done." + fi + + #add afxrdns + if [ ! -e ${mypath}/axfrdns ] + then + einfo "Setting up axfrdns..." + /usr/bin/axfrdns-conf tinydns dnslog \ + ${mypath}/axfrdns ${mypath}/tinydns $myip + else + ewarn "*** axfrdns directory currently exists, nothing done." + fi + + #grant access to axfrdns + + echo + echo + einfo "Start service" + echo + echo "tinydns is ready for startup." + echo "Do you want dnscache to be started and" + echo "supervised by daemontools now?" + + echo + echo "This requires daemontools to supervise" + echo "/service !!" + echo + echo '(press control-C to abort)' + read + + # Don't make symbolic links to / ! + # use ../ instead as it gives trouble in chrooted environments + # By Kalin KOZHUHAROV + local fixedroot_path=`echo ${mypath} | sed -e 's#^/#../#'` + cd /service + ln -sf ${fixedroot_path}/tinydns . + ln -sf ${fixedroot_path}/axfrdns . + + echo + echo + einfo "Installation successfull" + echo + +} + +# check for root user! +if [ `id -u` -ne 0 ] +then + eerror "${0}: must be root." + exit 1 +fi + + +# run setup +setup