]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - djbdns/files/tinydns-setup
skel.ebuild: use EAPI=8.
[mjo-overlay.git] / djbdns / files / tinydns-setup
1 #!/bin/bash
2
3 #
4 # source functions.sh for einfo, eerror and ewarn
5 . /etc/init.d/functions.sh
6
7 setup() {
8 echo
9 echo
10 einfo "tinydns Setup"
11 echo
12 echo ">>> More information on this package can be found at"
13 echo ">>> http://cr.yp.to/djbdns/tinydns.html"
14 echo
15 echo "If you have previously setup tinydns, those directories will"
16 echo "not be overwritten. To redo setup, delete your"
17 echo "tinydns dir tree first."
18 echo
19 echo '(press enter to begin setup, or press control-C to abort)'
20 echo
21 read
22
23 echo
24 einfo "Install location"
25 echo
26 echo "Where do you want tinydns installed?"
27 echo "Ex. /var would install dnscache in /var/tinydns."
28 echo "!!No trailing slash!!"
29 echo
30 read -p "[/var]> " mypath
31 echo
32
33 if [ "$mypath" == "" ]
34 then
35 mypath="/var"
36 fi
37
38 if [ ! -e ${mypath} ]
39 then
40 echo ">>> Creating ${mypath}..."
41 mkdir $mypath
42 fi
43
44 # check for existance of users tinydns and dnslog:
45 echo
46 echo
47 einfo "Checking for tinydns and dnslog user accts ..."
48 echo
49 /usr/bin/grep nofiles /etc/group &> /dev/null
50 if [ $? -ne 0 ]
51 then
52 echo ">>> Adding group nofiles ..."
53 /usr/sbin/groupadd nofiles &> /dev/null
54 fi
55
56 /usr/bin/grep tinydns /etc/passwd &> /dev/null
57 if [ $? -ne 0 ]
58 then
59 echo ">>> Adding user tinydns ..."
60 /usr/sbin/useradd -d /dev/null -s /bin/false -g nofiles \
61 tinydns &> /dev/null
62 fi
63
64 /usr/bin/grep dnslog /etc/passwd &> /dev/null
65 if [ $? -ne 0 ]
66 then
67 echo ">>> Adding user dnslog ..."
68 /usr/sbin/useradd -d /dev/null -s /bin/false -g nofiles \
69 dnslog &> /dev/null
70 fi
71
72
73 # grab interfaces
74 addrs=`ifconfig -a | grep "inet addr" | cut -f2 -d":" | cut -f1 -d" "`
75
76 echo "Specify an address to which tinydns should bind."
77 echo "NOTICE: tinydns must be able to bind to port 53 on "
78 echo "choosen ip address! udp by tinydns - tcp by axfrdns"
79 echo "Usually this is NOT 127.0.0.1"
80 echo "Currently running IP addresses:"
81 echo
82 echo $addrs
83 echo
84
85 while [ "$myip" = "" ]
86 do
87 read -p "IP to bind nameserver to>" myip
88 done
89 echo
90
91 if [ ! -e ${mypath}/tinydns ]
92 then
93 einfo "Setting up tinydns..."
94 /usr/bin/tinydns-conf tinydns dnslog \
95 ${mypath}/tinydns $myip
96 else
97 ewarn "*** tinydns directory currently exists, nothing done."
98 fi
99
100 #add afxrdns
101 if [ ! -e ${mypath}/axfrdns ]
102 then
103 einfo "Setting up axfrdns..."
104 /usr/bin/axfrdns-conf tinydns dnslog \
105 ${mypath}/axfrdns ${mypath}/tinydns $myip
106 else
107 ewarn "*** axfrdns directory currently exists, nothing done."
108 fi
109
110 #grant access to axfrdns
111
112 echo
113 echo
114 einfo "Start service"
115 echo
116 echo "tinydns is ready for startup."
117 echo "Do you want dnscache to be started and"
118 echo "supervised by daemontools now?"
119
120 echo
121 echo "This requires daemontools to supervise"
122 echo "/service !!"
123 echo
124 echo '(press control-C to abort)'
125 read
126
127 # Don't make symbolic links to / !
128 # use ../ instead as it gives trouble in chrooted environments
129 # By Kalin KOZHUHAROV <kalin@ThinRope.net>
130 local fixedroot_path=`echo ${mypath} | sed -e 's#^/#../#'`
131 cd /service
132 ln -sf ${fixedroot_path}/tinydns .
133 ln -sf ${fixedroot_path}/axfrdns .
134
135 echo
136 echo
137 einfo "Installation successfull"
138 echo
139
140 }
141
142 # check for root user!
143 if [ `id -u` -ne 0 ]
144 then
145 eerror "${0}: must be root."
146 exit 1
147 fi
148
149
150 # run setup
151 setup