#!/bin/sh
# Time-stamp: <00/10/17 13:15:46 drt>

# Quick and dirty dnscache setup for people which don't really care.
# it downloads and installs djbdns and daemontools and sets up
# dnscache to run under supervise on 127.0.0.1. Hacked by
# drt@un.bewaff.net and j.ohlig@twisd.de.

# Location of your local startup-script. You probably have to change
# this.

# BSD
#RCLOCAL=/etc/rc.local

# RedHat Linux
#RCLOCAL=/etc/rc.d/rc.local

#Debian GNU/Linux
RCLOCAL=/etc/init.d/bootmisc.sh

# UID to runn the server
SVRUID=daemon
LOGUID=daemon

cd /tmp
wget http://cr.yp.to/djbdns/djbdns-1.02.tar.gz
tar xzvf djbdns-1.02.tar.gz
cd djbdns-1.02
make setup
cd ..
wget http://cr.yp.to/daemontools/daemontools-0.70.tar.gz
tar xzvf daemontools-0.70.tar.gz
cd daemontools-0.70 
make setup 
cd ..
rm -Rf /tmp/daemontools-0.70* /tmp/djbdns-1.02*
mkdir /var/service
/usr/local/bin/dnscache-conf $LOGUID $SVRUID /var/service/dnscache
mkdir /service
chmod 755 /service
echo "2>&1 env - PATH=/usr/local/bin:/usr/sbin:/usr/bin:/bin csh -cf 'svscan /service &'" >> $RCLOCAL
ln -sv /var/service/dnscache /service
echo  "nameserver 127.0.0.1" > /tmp/r.c
cat /etc/resolv.conf >> /tmp/r.c
mv /tmp/r.c /etc/resolv.conf
