]>
gitweb.michael.orlitzky.com - mjo-overlay.git/blob - djbdns/files/dnscache-setup
3 #for einfo, ewarn etc..
4 .
/etc
/init.d
/functions.sh
12 echo ">>> More information on this package can be found at"
13 echo ">>> http://cr.yp.to/djbdns.html and http://djbdns.org"
15 echo "After this script completes, dnscache will be configured."
16 echo "Your /etc/resolv.conf will be updated so that all DNS"
17 echo "lookups will be directed to dnscache."
19 echo "Your original /etc/resolv.conf will be backed up to "
20 echo "/etc/resolv.conf.orig."
22 echo "If you have previously setup dnscache, those directories will"
23 echo "not be overwritten. To redo setup, delete your dnscache"
24 echo "dirs first or choose a different install location."
26 echo '(press enter to begin setup, or press control-C to abort)'
31 einfo
"Install location"
33 echo "Where do you want dnscache installed?"
34 echo "Ex. Default (/var) will install dnscache in /var/dnscache,"
35 echo "or an external cache in /var/dnscachex."
36 echo "!!No trailing slash!!"
38 read -p "[/var]> " mypath
41 if [ "$mypath" == "" ]
48 echo ">>> Creating ${mypath}..."
54 einfo
"Internal or external cache?"
56 echo "Specify an address to which dnscache should bind."
57 echo "If this is the only machine accessing dnscache,"
58 echo "127.0.0.1 is a good start."
59 echo "Currently running IP addresses:"
63 addrs
=`ifconfig -a | grep "inet addr" | cut -f2 -d":" | cut -f1 -d" "`
67 read -p "IP to bind cache to [127.0.0.1]> " myip
75 mycachedir
="dnscachex"
78 # check for existance of users dnscache and dnslog:
81 einfo
"Checking for dnscache and dnslog user accts ..."
83 /usr
/bin
/grep nofiles
/etc
/group
&> /dev
/null
86 echo ">>> Adding group nofiles ..."
87 /usr
/sbin
/groupadd nofiles
&> /dev
/null
90 /usr
/bin
/grep dnscache
/etc
/passwd
&> /dev
/null
93 echo ">>> Adding user dnscache ..."
94 /usr
/sbin
/useradd
-d /dev
/null
-s /bin
/false
-g nofiles \
98 /usr
/bin
/grep dnslog
/etc
/passwd
&> /dev
/null
101 echo ">>> Adding user dnslog ..."
102 /usr
/sbin
/useradd
-d /dev
/null
-s /bin
/false
-g nofiles \
106 if [ ! -e ${mypath}/${mycachedir} ]
108 /usr
/bin
/dnscache
-conf dnscache dnslog \
109 ${mypath}/${mycachedir} ${myip}
111 ewarn
"*** dnscache directory currently exists, nothing done."
116 einfo
"Configure a forward for dnscache?"
118 echo "dnscache can be configured to forward queries to another"
119 echo "nameserver (such as the nameserver of your ISP) rather than "
120 echo "perform the lookups itself. If you would like to enable this "
121 echo "forwarding mode (a good idea most of the time), then enter the "
122 echo "IP's of your forwarding nameservers now,"
123 echo "otherwise just hit Enter."
125 read -p "enter forward-to IP> " myforward
127 if [ "$myforward" != "" ]
129 echo $myforward > ${mypath}/${mycachedir}/root
/servers
/\@
130 echo -n "1" > ${mypath}/${mycachedir}/env
/FORWARDONLY
132 read -p "enter forward-to IP [hit Enter to stop]> " myforward
133 while [ "$myforward" != "" ]
135 echo $myforward >> ${mypath}/${mycachedir}/root
/servers
/\@
136 read -p "enter forward-to IP [hit Enter to stop]> " myforward
138 echo ">>> Setting up forwarding..."
141 if [ "$myip" != "127.0.0.1" ]
145 einfo
"Configuring clients"
147 echo "dnscache by default only allows 127.0.0.1 to access it."
148 echo "You have to specify the IP addresses of the clients"
149 echo "that shall be allowed to use dnscache."
151 echo "1.2.3.4 would allow host 1.2.3.4"
152 echo "1.2.3 would allow all hosts underneath 1.2.3.x"
154 echo "Just hit Enter if you do not want to specify clients!"
157 read -p "Enter IP> " myclientip
159 while [ "$myclientip" != "" ]
161 touch ${mypath}/${mycachedir}/root
/ip
/${myclientip}
162 read -p "Enter IP (hit Enter to stop)>" myclientip
170 if [ ! -e /var
/log
/dnscache
]
172 echo ">>> linking /var/log/${mycachedir} to the $mycachedir log..."
173 ln -s ${mypath}/${mycachedir}/log
/main
/var
/log
/${mycachedir}
176 if [ -e /etc
/resolv.conf
]
178 /usr
/bin
/grep $myip /etc
/resolv.conf
&> /dev
/null
181 echo ">>> Backing up /etc/resolv.conf to resolv.conf.orig..."
182 cp /etc
/resolv.conf
/etc
/resolv.conf.orig
183 cat /etc
/resolv.conf.orig
| grep -v nameserver
> /etc
/resolv.conf
184 echo ">>> Removed nameserver entries from resolv.conf..."
185 echo nameserver
$myip >> /etc
/resolv.conf
187 echo ">>> Added \"nameserver ${myip}\" to /etc/resolv.conf!"
189 echo ">>> ${myip} is already in /etc/resolv.conf - nothing done!"
192 echo nameserver
$myip >> /etc
/resolv.conf
194 echo ">>> Added \"nameserver ${myip}\" to /etc/resolv.conf!"
198 #configure cachsize - $mypath/env/CACHESIZE
201 #configure datalimit - $mypath/env/DATALIMIT
205 einfo
"Start service"
207 echo "dnscache is ready for startup."
208 echo "Do you want dnscache to be started and"
209 echo "supervised by daemontools now?"
212 echo "This requires svscan (daemontools) to be running currently and"
213 echo "monitoring /service !!"
215 echo '(press control-C to abort)'
218 # check in /mnt/.init.d to find svscan link in running...
219 # if not running execute /etc/init.d/svscan start
220 # Don't make symbolic links to / !
221 # use ../ instead as it gives trouble in chrooted environments
222 # By Kalin KOZHUHAROV <kalin@ThinRope.net>
223 local fixedroot_path
=`echo ${mypath} | sed -e 's#^/#../#'`
225 ln -sf ${fixedroot_path}/${mycachedir} .
229 einfo
"Installation successfull"
233 # check for root user
237 eerror
"${0}: must be root."