Mercurial > hg > anonet-resdb
comparison contrib/peer2anonet/peer2anonet-gentoo @ 1043:ae67d952429a draft
deleted: contrib/peer2anonet/p2a.conf
deleted: contrib/peer2anonet/peer2anonet-gentoo
deleted: db/dom/Anonymous/ns/Anonymous
deleted: db/dom/Anonymous/ns/Coward
deleted: db/dom/Anonymous/ns/c.ns.talamon.ano
deleted: db/dom/Anonymous/owner
deleted: db/usr/Anonymous Coward/email
deleted: db/usr/Anonymous Coward/git
deleted: doc/www.anonet2.org/public_pod/.index.pod.swp
author | talamon <nobody@nowhere> |
---|---|
date | Mon, 29 Oct 2012 05:27:40 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1042:b211722679fb | 1043:ae67d952429a |
---|---|
1 #!/bin/bash | |
2 if [[ $(id -u) != 0 ]]; then | |
3 echo "peer2anonet: root privileges required." | |
4 exit 1 | |
5 fi | |
6 | |
7 if [ -e /services/bird ]; then | |
8 [ -e /etc/peer2anonet/bird.tar ] || ( cd /services ; echo "creating /etc/peer2anonet/bird.tar backup" ;\ | |
9 tar cf /etc/peer2anonet/bird.tar bird ) | |
10 fi | |
11 | |
12 [ -e contrib/peer2anonet/peer2anonet ] || echo "peer2anonet: not in \$RESDB_ROOT" | |
13 [ -e contrib/peer2anonet/peer2anonet ] || exit 1 | |
14 | |
15 [ -w /etc/rc.local ] && chmod +x /etc/rc.local | |
16 [ -w /etc/rc.d/rc.local ] && chmod +x /etc/rc.d/rc.local | |
17 | |
18 USAGE(){ | |
19 echo -e '\npeer2anonet:' | |
20 echo -e '\n ./contrib/peer2anonet/peer2anonet --configure generate a new local configuration and exit' | |
21 echo -e '\n ./contrib/peer2anonet/peer2anonet --update regenerate peer configurations' | |
22 echo -e '\n ./contrib/peer2anonet/peer2anonet --configure-peer generate a new peer configuration and update' | |
23 echo -e '\n ./contrib/peer2anonet/peer2anonet --rm-peer remove a peer configuration and update' | |
24 echo -e '\n ./contrib/peer2anonet/peer2anonet --install-daemontools installs daemontools' | |
25 echo -e '\n ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp installs ucspi-tcp' | |
26 echo -e '\n ./contrib/peer2anonet/peer2anonet --install-djbdns installs djbdns' | |
27 echo -e '\n ./contrib/peer2anonet/peer2anonet --install-nacl installs nacl' | |
28 echo -e '\n ./contrib/peer2anonet/peer2anonet --setup-qmail installs and configures qmail' | |
29 echo -e '\n ./contrib/peer2anonet/peer2anonet --configure-dns configures dnscache and tinydns zones' | |
30 echo -e '\n ./contrib/peer2anonet/peer2anonet --update-dns updates tinydns-ano zone\n' | |
31 exit 0 | |
32 } | |
33 | |
34 mkdir -p /service | |
35 mkdir -p /services | |
36 mkdir -p /services/bird | |
37 mkdir -p /etc/peer2anonet | |
38 mkdir -p /etc/peer2anonet/peers | |
39 | |
40 CONFIGURE(){ | |
41 echo -e '\nCONFIGURE:\n' | |
42 read -p " Enter your AnoNet subnet: " P2A_NET | |
43 read -p " Enter your AnoNet router: " P2A_ROUTE | |
44 read -p " Enter your peering ip: " P2A_IP | |
45 read -p " Enter your AnoNet asn: " P2A_ASN | |
46 | |
47 | |
48 echo "P2A_NET=\"$P2A_NET\"">/etc/peer2anonet/p2a.conf | |
49 echo "P2A_ROUTE=\"$P2A_ROUTE\"">>/etc/peer2anonet/p2a.conf | |
50 echo "P2A_IP=\"$P2A_IP\"">>/etc/peer2anonet/p2a.conf | |
51 echo "P2A_ASN=\"$P2A_ASN\"">>/etc/peer2anonet/p2a.conf | |
52 echo -e '\npeer2anonet: configured\n' | |
53 | |
54 NICK=`cat conf/git_name` | |
55 ./scripts/add_as $P2A_ASN $NICK | |
56 ./scripts/add_ip $P2A_NET/24 $NICK | |
57 [ -e "db/usr/$NICK" ] || mkdir -p "db/usr/$NICK" | |
58 [ -e "db/usr/$NICK/git" ] || echo "git://git.$NICK.ano/">"db/usr/$NICK/git" | |
59 [ -e "db/usr/$NICK/email" ] || echo "`cat conf/git_email`">"db/usr/$NICK/email" | |
60 exit 0 | |
61 } | |
62 | |
63 UPDATE(){ | |
64 if [ -e /etc/peer2anonet/p2a.conf ]; then | |
65 source /etc/peer2anonet/p2a.conf | |
66 else | |
67 CONFIGURE | |
68 exit 0 | |
69 fi | |
70 | |
71 echo -e '\nUPDATE:\n' | |
72 if [[ $(ls /etc/peer2anonet/peers) ]]; then | |
73 for PEER in `ls /etc/peer2anonet/peers`; do | |
74 if [ -e /etc/peer2anonet/peers/"$PEER"/remote_ip ]; then | |
75 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/remote_ip`) == 'X' ]]; then | |
76 echo " fatal error: /etc/peer2anonet/peers/$PEER/remote_ip is void" | |
77 exit 1 | |
78 fi | |
79 else | |
80 echo " fatal error: /etc/peer2anonet/peers/$PEER/remote_ip not exists" | |
81 exit 1 | |
82 fi | |
83 | |
84 if [ -e /etc/peer2anonet/peers/"$PEER"/peering_ip ]; then | |
85 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/peering_ip`) == 'X' ]]; then | |
86 echo " fatal error: /etc/peer2anonet/peers/$PEER/peering_ip is void" | |
87 exit 1 | |
88 fi | |
89 else | |
90 echo " fatal error: /etc/peer2anonet/peers/$PEER/peering_ip not exists" | |
91 exit 1 | |
92 fi | |
93 | |
94 if [ -e /etc/peer2anonet/peers/"$PEER"/remote_port ]; then | |
95 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/remote_port`) == 'X' ]]; then | |
96 echo " fatal error: /etc/peer2anonet/peers/$PEER/remote_port is void" | |
97 exit 1 | |
98 fi | |
99 else | |
100 echo " fatal error: /etc/peer2anonet/peers/$PEER/remote_port not exists" | |
101 exit 1 | |
102 fi | |
103 | |
104 if [ -e /etc/peer2anonet/peers/"$PEER"/local_port ]; then | |
105 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/local_port`) == 'X' ]]; then | |
106 echo " fatal error: /etc/peer2anonet/peers/$PEER/local_port is void" | |
107 exit 1 | |
108 fi | |
109 else | |
110 echo " fatal error: /etc/peer2anonet/peers/$PEER/local_port not exists" | |
111 exit 1 | |
112 fi | |
113 | |
114 if [ -e /etc/peer2anonet/peers/"$PEER"/asn ]; then | |
115 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/asn`) == 'X' ]]; then | |
116 echo " fatal error: /etc/peer2anonet/peers/$PEER/asn is void" | |
117 exit 1 | |
118 fi | |
119 else | |
120 echo " fatal error: /etc/peer2anonet/peers/$PEER/asn not exists" | |
121 exit 1 | |
122 fi | |
123 | |
124 if [ -e /etc/peer2anonet/peers/"$PEER"/pubkey ]; then | |
125 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/pubkey`) == 'X' ]]; then | |
126 echo " fatal error: /etc/peer2anonet/peers/$PEER/pubkey is void" | |
127 exit 1 | |
128 fi | |
129 else | |
130 echo " fatal error: /etc/peer2anonet/peers/$PEER/pubkey not exists" | |
131 exit 1 | |
132 fi | |
133 | |
134 if [ -e /etc/peer2anonet/peers/"$PEER"/seckey ]; then | |
135 if [[ $(echo X`cat /etc/peer2anonet/peers/"$PEER"/seckey`) == 'X' ]]; then | |
136 echo " fatal error: /etc/peer2anonet/peers/$PEER/seckey is void" | |
137 exit 1 | |
138 fi | |
139 else | |
140 echo " fatal error: /etc/peer2anonet/peers/$PEER/seckey not exists" | |
141 exit 1 | |
142 fi | |
143 done | |
144 else | |
145 echo " fatal error: peering configurations not exists" | |
146 exit 1 | |
147 fi | |
148 | |
149 echo '#!/bin/bash | |
150 bird -c bird.conf -d' > /services/bird/run | |
151 chmod +x /services/bird/run | |
152 | |
153 if [ -e /etc/peer2anonet/bird.conf ]; then | |
154 cp /etc/peer2anonet/bird.conf /services/bird/bird.conf | |
155 else | |
156 echo "function n_AnoNet_mine (prefix arg) { | |
157 if arg ~ [ $P2A_NET/24+ ] then return true; | |
158 return false; }; | |
159 | |
160 function n_AnoNet (prefix arg) { | |
161 if arg ~ [ 1.0.0.0/8+ ] then return true; | |
162 return false; }; | |
163 | |
164 filter only_AnoNet_ebgp { | |
165 if n_AnoNet(net) then | |
166 if !n_AnoNet_mine(net) then | |
167 accept \"AnoNet\"; | |
168 else reject \"mine\"; | |
169 reject \"non-AnoNet\"; }; | |
170 | |
171 filter only_AnoNet_ebgp_export { | |
172 if n_AnoNet(net) then accept \"AnoNet\"; | |
173 reject \"non-AnoNet\"; }; | |
174 | |
175 filter only_AnoNet { | |
176 if n_AnoNet(net) then accept \"AnoNet\"; | |
177 reject \"non-AnoNet\"; }; | |
178 | |
179 table AnoNet_routes; | |
180 | |
181 protocol pipe pipe_AnoNet_routes { peer table AnoNet_routes; mode transparent; | |
182 import filter only_AnoNet; | |
183 export filter only_AnoNet; | |
184 }; | |
185 | |
186 protocol static static_AnoNet_routes { table AnoNet_routes; | |
187 route $P2A_NET/24 drop; | |
188 } | |
189 | |
190 protocol kernel { | |
191 scan time 10; | |
192 import all; | |
193 export all; | |
194 } | |
195 | |
196 protocol device { | |
197 scan time 900; | |
198 } | |
199 | |
200 protocol direct direct_AnoNet_routes { table AnoNet_routes; | |
201 interface \"eth0\"; | |
202 import filter only_AnoNet; | |
203 }" > /services/bird/bird.conf | |
204 fi | |
205 | |
206 for PEER in `ls /etc/peer2anonet/peers`; do | |
207 mkdir -p /services/"$PEER" | |
208 REMOTEIP=`cat /etc/peer2anonet/peers/"$PEER"/remote_ip` | |
209 PEERIP=`cat /etc/peer2anonet/peers/"$PEER"/peering_ip` | |
210 PEERPORT=`cat /etc/peer2anonet/peers/"$PEER"/remote_port` | |
211 LOCALPORT=`cat /etc/peer2anonet/peers/"$PEER"/local_port` | |
212 PEERASN=`cat /etc/peer2anonet/peers/"$PEER"/asn` | |
213 PUBKEY=`cat /etc/peer2anonet/peers/"$PEER"/pubkey` | |
214 SECKEY=`cat /etc/peer2anonet/peers/"$PEER"/seckey` | |
215 | |
216 echo " | |
217 protocol bgp $PEER { table AnoNet_routes; | |
218 local as $P2A_ASN; | |
219 neighbor $PEERIP as $PEERASN; | |
220 source address $P2A_IP; | |
221 import filter only_AnoNet_ebgp; | |
222 export filter only_AnoNet_ebgp_export; | |
223 }" >> /services/bird/bird.conf | |
224 | |
225 if [ -e /etc/peer2anonet/peers/"$PEER"/run ]; then | |
226 test -L /services/"$PEER"/run || rm -f /services/"$PEER"/run | |
227 test -L /services/"$PEER"/run || ln -s /etc/peer2anonet/peers/"$PEER"/run /services/"$PEER"/run | |
228 else | |
229 echo "#!/bin/bash | |
230 | |
231 # uncomment for debugging. you'll need to use ./run to view output instead | |
232 # of svc -u /service/<peer name> | |
233 # | |
234 #export DEBUG=1 | |
235 | |
236 # uncomment if your peer has a dynamic IP | |
237 # | |
238 #export REMOTE_FLOAT=1 | |
239 | |
240 if [[ \$REMOTE_FLOAT != 1 ]]; then | |
241 export REMOTE_ADDRESS=\`cat /etc/peer2anonet/peers/$PEER/remote_ip\` | |
242 export REMOTE_PORT=\`cat /etc/peer2anonet/peers/$PEER/remote_port\` | |
243 fi | |
244 | |
245 # not recommended to change these values | |
246 # | |
247 export LOCAL_PORT=\`cat /etc/peer2anonet/peers/$PEER/local_port\` | |
248 export PRIVATE_KEY=\`cat /etc/peer2anonet/peers/$PEER/seckey\` | |
249 export PUBLIC_KEY=\`cat /etc/peer2anonet/peers/$PEER/pubkey\` | |
250 export TUN_MODE=1 | |
251 export INTERFACE=ppp-$PEER | |
252 | |
253 # uncomment if you want to nuke your default gateway and configure | |
254 # routes only to peers through IcannNet. If any of your peers use | |
255 # dynamic IP's or you use Tor or i2p then this is probably NOT a | |
256 # good idea. You may need to modify the DEFAULT_ROUTE code below. | |
257 # If you run into problems with this please /msg /relayhell/d3v11 | |
258 # so I can create a patch. | |
259 # | |
260 #DEFAULT_ROUTE=\`ip route show | grep default | cut -d' ' -f 3\` | |
261 #route del default gw \$DEFAULT_ROUTE | |
262 #route add \$REMOTE_ADDRESS gw \$DEFAULT_ROUTE | |
263 | |
264 ( sleep 5; | |
265 ip addr add $P2A_IP peer \`cat /etc/peer2anonet/peers/$PEER/peering_ip\`/32 dev \$INTERFACE scope link | |
266 ip addr add $P2A_ROUTE/32 dev \$INTERFACE scope global | |
267 ip link set dev \$INTERFACE up | |
268 | |
269 # comment the following ping line to remove pinghack. this is a | |
270 # trick used to help bird connect. | |
271 # | |
272 ping -c 1 -I \$INTERFACE \`cat /etc/peer2anonet/peers/$PEER/peering_ip\` -r -w 5 | |
273 | |
274 ) & | |
275 exec /usr/sbin/quicktun.nacltai" > /etc/peer2anonet/peers/$PEER/run | |
276 fi | |
277 chmod +x /etc/peer2anonet/peers/"$PEER"/run | |
278 test -L /services/"$PEER"/run || rm -f /services/"$PEER"/run | |
279 test -L /services/"$PEER"/run || ln -s /etc/peer2anonet/peers/"$PEER"/run /services/"$PEER"/run | |
280 test -L "/service/$PEER" && svc -t "/service/$PEER" | |
281 test -L "/service/$PEER" || ln -s "/services/$PEER" "/service/$PEER" | |
282 done | |
283 test -L /service/bird || ln -s /services/bird /service/bird | |
284 echo configure | birdc | |
285 } | |
286 | |
287 CONFIGURE_PEER(){ | |
288 if [ -e /etc/peer2anonet/p2a.conf ]; then | |
289 source /etc/peer2anonet/p2a.conf | |
290 else | |
291 CONFIGURE | |
292 exit 0 | |
293 fi | |
294 | |
295 echo -e '\nCONFIGURE PEER:\n' | |
296 read -p " Enter your peer's name: " PEER | |
297 read -p " Enter your peer's remote ip: " REMOTEIP | |
298 read -p " Enter your peer's peering ip: " PEERIP | |
299 read -p " Enter your peer's remote port: " PEERPORT | |
300 read -p " Enter your local port: " LOCALPORT | |
301 read -p " Enter your peer's asn: " PEERASN | |
302 read -p " Enter your peer's public key: " PUBKEY | |
303 read -p " Enter your private key: " SECKEY | |
304 [ -e /etc/peer2anonet/peers/"$PEER" ] && rm -r /etc/peer2anonet/peers/"$PEER" | |
305 mkdir -p /etc/peer2anonet/peers/"$PEER" | |
306 echo $REMOTEIP >/etc/peer2anonet/peers/"$PEER"/remote_ip | |
307 echo $PEERIP >/etc/peer2anonet/peers/"$PEER"/peering_ip | |
308 echo $PEERPORT >/etc/peer2anonet/peers/"$PEER"/remote_port | |
309 echo $LOCALPORT >/etc/peer2anonet/peers/"$PEER"/local_port | |
310 echo $PEERASN >/etc/peer2anonet/peers/"$PEER"/asn | |
311 echo $PUBKEY >/etc/peer2anonet/peers/"$PEER"/pubkey | |
312 echo $SECKEY >/etc/peer2anonet/peers/"$PEER"/seckey | |
313 echo -e "\n configured $PEER\n" | |
314 } | |
315 | |
316 RM_PEER(){ | |
317 if [ -e /etc/peer2anonet/p2a.conf ]; then | |
318 source /etc/peer2anonet/p2a.conf | |
319 else | |
320 CONFIGURE | |
321 exit 0 | |
322 fi | |
323 | |
324 echo -e '\nRM PEER:\n' | |
325 read -p " Enter your peer's name: " PEER | |
326 if [ -e /etc/peer2anonet/peers/"$PEER" ]; then | |
327 rm -r /etc/peer2anonet/peers/"$PEER" | |
328 echo | |
329 echo -e " removed /etc/peer2anonet/peers/$PEER\n" | |
330 else | |
331 echo | |
332 echo -e " fatal error: /etc/peer2anonet/peers/$PEER not exists\n" | |
333 exit 1 | |
334 fi | |
335 } | |
336 | |
337 INSTALL_DAEMONTOOLS(){ | |
338 echo -e '\nINSTALL DAEMONTOOLS:\n' | |
339 [[ $(echo X`which gcc`) == X ]] && echo ' fatal error: cannot find gcc' | |
340 [[ $(echo X`which gcc`) == X ]] && exit 1 | |
341 [[ $(echo X`which make`) == X ]] && echo ' fatal error: cannot find make' | |
342 [[ $(echo X`which make`) == X ]] && exit 1 | |
343 | |
344 if [ -w /etc/inittab ]; then : | |
345 elif [ -w /etc/rc.local ] && ! [ -w /etc/inittab ]; then | |
346 sed -i "s/exit 0/exec \/command\/svscanboot \&/" /etc/rc.local | |
347 chmod +x /etc/rc.local | |
348 else | |
349 echo ' fatal error: cannot create reliable startup' | |
350 exit 1 | |
351 fi | |
352 | |
353 mkdir -p /package | |
354 chmod 1755 /package | |
355 cd /package | |
356 wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz | |
357 gunzip daemontools-0.76.tar | |
358 tar -xpf daemontools-0.76.tar | |
359 rm -f daemontools-0.76.tar | |
360 cd admin/daemontools-0.76 | |
361 sed -i 's/gcc/gcc -include errno.h/g' src/conf-cc | |
362 package/install | |
363 exec /command/svscanboot >/dev/null 2>&1 & | |
364 } | |
365 | |
366 INSTALL_UCSPI_TCP(){ | |
367 echo -e '\nINSTALL UCSPI-TCP:\n' | |
368 [[ $(echo X`which gcc`) == X ]] && echo ' fatal error: cannot find gcc' | |
369 [[ $(echo X`which gcc`) == X ]] && exit 1 | |
370 [[ $(echo X`which make`) == X ]] && echo ' fatal error: cannot find make' | |
371 [[ $(echo X`which make`) == X ]] && exit 1 | |
372 cd /usr/local/src | |
373 wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz | |
374 gunzip ucspi-tcp-0.88.tar | |
375 tar -xf ucspi-tcp-0.88.tar | |
376 cd ucspi-tcp-0.88 | |
377 sed -i 's/gcc/gcc -include errno.h/g' conf-cc | |
378 make | |
379 make setup check | |
380 } | |
381 | |
382 SETUP_QMAIL(){ | |
383 echo -e '\nSETUP QMAIL:\n' | |
384 | |
385 echo -e '\tWARN:\n' | |
386 echo -e '\tYou should patch or firewall off qmail from' | |
387 echo -e '\treaching IcannNet so someone cannot harvest' | |
388 echo -e '\tyour IP with the mailerdaemon response.' | |
389 | |
390 [[ $(echo X`which gcc`) == X ]] && echo ' fatal error: cannot find gcc' | |
391 [[ $(echo X`which gcc`) == X ]] && exit 1 | |
392 [[ $(echo X`which make`) == X ]] && echo ' fatal error: cannot find make' | |
393 [[ $(echo X`which make`) == X ]] && exit 1 | |
394 [[ $(echo X`which tcpserver`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp' | |
395 [[ $(echo X`which tcpserver`) == X ]] && exit 1 | |
396 [[ $(echo X`which svscanboot`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-daemontools' | |
397 [[ $(echo X`which svscanboot`) == X ]] && exit 1 | |
398 | |
399 NICK=`cat conf/git_name` || exit 1 | |
400 MX_IP=`cat conf/gitd_ip` || exit 1 | |
401 MX_DOMAIN="a.mx.$NICK.ano" || exit 1 | |
402 | |
403 if [ -e /services/tinydns ]; then | |
404 ( | |
405 cd /services | |
406 echo "creating /etc/peer2anonet/tinydns.tar backup" | |
407 tar cf /etc/peer2anonet/tinydns.tar tinydns | |
408 echo "@$NICK.ano:$MX_IP:a:12801:86400">>/services/tinydns/root/data | |
409 ) | |
410 else | |
411 echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --configure-dns' | |
412 exit 1 | |
413 fi | |
414 | |
415 ( | |
416 cd /services/tinydns/root | |
417 make | |
418 cd /service | |
419 sleep 5 | |
420 svc -t dnscache tinydns tinydns-ano tinydns-root | |
421 ) | |
422 | |
423 useradd qmaillog || exit 1 | |
424 | |
425 if [ -w /etc/rc.local ]; then | |
426 if [[ $(cat /etc/rc.local) != *"ip addr add $MX_IP/32 dev lo &"* ]]; then | |
427 echo "ip addr add $MX_IP/32 dev lo &" >> /etc/rc.local | |
428 fi | |
429 elif [ -w /etc/rc.d/rc.local ]; then | |
430 if [[ $(cat /etc/rc.d/rc.local) != *"ip addr add $MX_IP/32 dev lo &"* ]]; then | |
431 echo "ip addr add $MX_IP/32 dev lo &" >> /etc/rc.d/rc.local | |
432 fi | |
433 else | |
434 echo " fatal error: cannot reliably assign ip's to startup" | |
435 exit 1 | |
436 fi | |
437 | |
438 ip addr add $MX_IP/32 dev lo > /dev/null 2>&1 | |
439 | |
440 if [ -e '/var/qmail/bin/qmail-qmtpd' ] || ! [ -e '/var/qmail/bin/qmail-smtpd' ]; then | |
441 cd /usr/local/src | |
442 wget http://www.srn.ano/software/qmail-1.03.tar.gz | |
443 tar xzf qmail-1.03.tgz | |
444 cd qmail-1.03 | |
445 unset http_proxy | |
446 wget -O- http://www.srn.ano/patches/qmail-1.03-qmtpc.patch | patch -p1 | |
447 mkdir /var/qmail | |
448 groupadd nofiles | |
449 useradd -g nofiles -d /var/qmail/alias alias | |
450 useradd -g nofiles -d /var/qmail qmaild | |
451 useradd -g nofiles -d /var/qmail qmaill | |
452 useradd -g nofiles -d /var/qmail qmailp | |
453 groupadd qmail | |
454 useradd -g qmail -d /var/qmail qmailq | |
455 useradd -g qmail -d /var/qmail qmailr | |
456 useradd -g qmail -d /var/qmail qmails | |
457 sed -i 's/gcc/gcc -include errno.h/g' conf-cc | |
458 make setup check | |
459 ./config-fast $MX_DOMAIN | |
460 echo yourdomain.ano >>/var/qmail/control/locals | |
461 echo yourdomain.ano >>/var/qmail/control/rcpthosts | |
462 (cd ~alias; touch .qmail-postmaster .qmail-mailer-daemon .qmail-root) | |
463 chmod 644 ~alias/.qmail* | |
464 fi | |
465 | |
466 mkdir -p /services/qmail | |
467 mkdir -p /services/qmail/log | |
468 mkdir -p /services/qmail/log/main | |
469 chown qmaillog /services/qmail/log/main | |
470 echo -e '#!/bin/sh\nexec env - PATH="/var/qmail/bin:/usr/local/bin:/usr/bin:/bin" qmail-start ./Mailbox' >/services/qmail/run | |
471 chmod +x /services/qmail/run | |
472 echo -e '#!/bin/sh\nexec setuidgid qmaillog multilog t s10000 n4 ./main' >/services/qmail/log/run | |
473 chmod +x /services/qmail/log/run | |
474 | |
475 ( cd / ; ln -s /services/qmail /service ) | |
476 | |
477 mkdir -p /services/qmail-smtpd | |
478 mkdir -p /services/qmail-smtpd/log | |
479 mkdir -p /services/qmail-smtpd/log/main | |
480 chown qmaillog /services/qmail-smtpd/log/main | |
481 echo -e echo -e '#!/bin/sh\nexec envuidgid qmaild tcpserver -U -c 100 '$MX_IP' smtp /var/qmail/bin/qmail-smtpd' >/services/qmail-smtpd/run | |
482 chmod +x /services/qmail-smtpd/run | |
483 echo -e '#!/bin/sh\nexec setuidgid qmaillog multilog t s10000 n4 ./main' >/services/qmail-smtpd/log/run | |
484 chmod +x /services/qmail-smtpd/log/run | |
485 | |
486 ( cd / ; ln -s /services/qmail-smtpd /service ) | |
487 | |
488 mkdir -p /services/qmail-qmtpd | |
489 mkdir -p /services/qmail-qmtpd/log | |
490 mkdir -p /services/qmail-qmtpd/log/main | |
491 chown qmaillog /services/qmail-qmtpd/log/main | |
492 echo -e echo -e '#!/bin/sh\nexec envuidgid qmaild tcpserver -U -c 100 '$MX_IP' qmtp /var/qmail/bin/qmail-qmtpd' >/services/qmail-qmtpd/run | |
493 chmod +x /services/qmail-qmtpd/run | |
494 echo -e '#!/bin/sh\nexec setuidgid qmaillog multilog t s10000 n4 ./main' >/services/qmail-qmtpd/log/run | |
495 chmod +x /services/qmail-qmtpd/log/run | |
496 | |
497 ( cd / ; ln -s /services/qmail-qmtpd /service ) | |
498 | |
499 ( | |
500 cd / | |
501 [ -e /usr/sbin/sendmail ] && mv /usr/sbin/sendmail /usr/sbin/sendmail.bak | |
502 ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail | |
503 ) | |
504 | |
505 echo 'export MAIL=~/Mailbox' >>/etc/profile | |
506 } | |
507 | |
508 INSTALL_DJBDNS(){ | |
509 echo -e '\nINSTALL DJBDNS:\n' | |
510 [[ $(echo X`which gcc`) == X ]] && echo ' fatal error: cannot find gcc' | |
511 [[ $(echo X`which gcc`) == X ]] && exit 1 | |
512 [[ $(echo X`which make`) == X ]] && echo ' fatal error: cannot find make' | |
513 [[ $(echo X`which make`) == X ]] && exit 1 | |
514 [[ $(echo X`which tcpserver`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp' | |
515 [[ $(echo X`which tcpserver`) == X ]] && exit 1 | |
516 [[ $(echo X`which svscanboot`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-daemontools' | |
517 [[ $(echo X`which svscanboot`) == X ]] && exit 1 | |
518 cd /usr/local/src | |
519 wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz | |
520 gunzip djbdns-1.05.tar | |
521 tar -xf djbdns-1.05.tar | |
522 cd djbdns-1.05 | |
523 echo gcc -O2 -include /usr/include/errno.h > conf-cc | |
524 make | |
525 make setup check | |
526 } | |
527 | |
528 CONFIGURE_DNS(){ | |
529 if [ -e /etc/peer2anonet/p2a.conf ]; then | |
530 source /etc/peer2anonet/p2a.conf | |
531 else | |
532 CONFIGURE | |
533 exit 0 | |
534 fi | |
535 | |
536 [[ $(echo X`which tcpserver`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp' | |
537 [[ $(echo X`which tcpserver`) == X ]] && exit 1 | |
538 [[ $(echo X`which svscanboot`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-daemontools' | |
539 [[ $(echo X`which svscanboot`) == X ]] && exit 1 | |
540 [[ $(echo X`which tinydns`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-djbdns' | |
541 [[ $(echo X`which tinydns`) == X ]] && exit 1 | |
542 | |
543 if [ -e /services/dnscache ]; then | |
544 [ -e /etc/peer2anonet/dnscache.tar ] || ( cd /services ; echo "creating /etc/peer2anonet/dnscache.tar backup" ;\ | |
545 tar cf /etc/peer2anonet/dnscache.tar dnscache ) | |
546 fi | |
547 if [ -e /services/tinydns ]; then | |
548 [ -e /etc/peer2anonet/tinydns.tar ] || ( cd /services ; echo "creating /etc/peer2anonet/tinydns.tar backup" ;\ | |
549 tar cf /etc/peer2anonet/tinydns.tar tinydns ) | |
550 fi | |
551 if [ -e /services/tinydns-ano ]; then | |
552 [ -e /etc/peer2anonet/tinydns-ano.tar ] || ( cd /services ; echo "creating /etc/peer2anonet/tinydns-ano.tar backup" ;\ | |
553 tar cf /etc/peer2anonet/tinydns-ano.tar tinydns-ano ) | |
554 fi | |
555 if [ -e /services/tinydns-root ]; then | |
556 [ -e /etc/peer2anonet/tinydns-root.tar ] || ( cd /services ; echo "creating /etc/peer2anonet/tinydns-root.tar backup" ;\ | |
557 tar cf /etc/peer2anonet/tinydns-root.tar tinydns-root ) | |
558 fi | |
559 | |
560 ( | |
561 cd /service | |
562 svc -d dnscache tinydns tinydns-ano tinydns-root >/dev/null 2>&1 | |
563 rm -f dnscache tinydns tinydns-ano tinydns-root | |
564 cd /services | |
565 rm -rf dnscache tinydns tinydns-ano tinydns-root | |
566 ) | |
567 | |
568 echo -e '\nCONFIGURE DNS:\n' | |
569 NICK=`cat conf/git_name` || exit 1 | |
570 TINYDNS_ROOT_IP=`cat conf/tinydns__rootsrvrip` || exit 1 | |
571 TINYDNS_ROOT_DOMAIN=`cat conf/tinydns__rootsrvrname` || exit 1 | |
572 TINYDNS_ANO_IP=`cat conf/tinydns__tldsrvrip` || exit 1 | |
573 TINYDNS_ANO_DOMAIN=`cat conf/tinydns__tldsrvrname` || exit 1 | |
574 TINYDNS_IP=`cat conf/tinydns__srvrip` || exit 1 | |
575 TINYDNS_DOMAIN=`cat conf/tinydns__srvrname` || exit 1 | |
576 GIT_IP=`cat conf/gitd_ip` || exit 1 | |
577 GIT_DOMAIN="git.$NICK.ano" | |
578 | |
579 ./scripts/add_dom $NICK.ano $NICK $TINYDNS_DOMAIN/$TINYDNS_IP > /dev/null 2>&1 | |
580 | |
581 if [ -w /etc/rc.local ]; then | |
582 if [[ $(cat /etc/rc.local) != *"ip addr add $TINYDNS_ROOT_IP/32 dev lo &"* ]]; then | |
583 echo "ip addr add $TINYDNS_ROOT_IP/32 dev lo &" >> /etc/rc.local | |
584 fi | |
585 if [[ $(cat /etc/rc.local) != *"ip addr add $TINYDNS_IP/32 dev lo &"* ]]; then | |
586 echo "ip addr add $TINYDNS_IP/32 dev lo &" >> /etc/rc.local | |
587 fi | |
588 if [[ $(cat /etc/rc.local) != *"ip addr add $TINYDNS_ANO_IP/32 dev lo &"* ]]; then | |
589 echo "ip addr add $TINYDNS_ANO_IP/32 dev lo &" >> /etc/rc.local | |
590 fi | |
591 if [[ $(cat /etc/rc.local) != *"ip addr add $GIT_IP/32 dev lo &"* ]]; then | |
592 echo "ip addr add $GIT_IP/32 dev lo &" >> /etc/rc.local | |
593 fi | |
594 elif [ -w /etc/rc.d/rc.local ]; then | |
595 if [[ $(cat /etc/rc.d/rc.local) != *"ip addr add $TINYDNS_ROOT_IP/32 dev lo &"* ]]; then | |
596 echo "ip addr add $TINYDNS_ROOT_IP/32 dev lo &" >> /etc/rc.d/rc.local | |
597 fi | |
598 if [[ $(cat /etc/rc.d/rc.local) != *"ip addr add $TINYDNS_IP/32 dev lo &"* ]]; then | |
599 echo "ip addr add $TINYDNS_IP/32 dev lo &" >> /etc/rc.d/rc.local | |
600 fi | |
601 if [[ $(cat /etc/rc.d/rc.local) != *"ip addr add $TINYDNS_ANO_IP/32 dev lo &"* ]]; then | |
602 echo "ip addr add $TINYDNS_ANO_IP/32 dev lo &" >> /etc/rc.d/rc.local | |
603 fi | |
604 if [[ $(cat /etc/rc.d/rc.local) != *"ip addr add $GIT_IP/32 dev lo &"* ]]; then | |
605 echo "ip addr add $GIT_IP/32 dev lo &" >> /etc/rc.d/rc.local | |
606 fi | |
607 else | |
608 ( | |
609 mkdir -p /services/tinydns-ips | |
610 echo "#!/bin/sh -e" > /services/tinydns-ips/run | |
611 echo "ip addr add $TINYDNS_ROOT_IP/32 dev lo &" >> /services/tinydns-ips/run | |
612 echo "ip addr add $TINYDNS_IP/32 dev lo &" >> /services/tinydns-ips/run | |
613 echo "ip addr add $TINYDNS_ANO_IP/32 dev lo &" >> /services/tinydns-ips/run | |
614 echo "ip addr add $GIT_IP/32 dev lo &" >> /services/tinydns-ips/run | |
615 echo "svc -d ." /services/tinydns-ips/run | |
616 chmod +x /services/tinydns-ips/run | |
617 test -L /service/tinydns-ips || ln -s /services/tinydns-ips /service/tinydns-ips | |
618 ) | |
619 fi | |
620 | |
621 ip addr add $TINYDNS_ROOT_IP/32 dev lo > /dev/null 2>&1 | |
622 ip addr add $TINYDNS_IP/32 dev lo > /dev/null 2>&1 | |
623 ip addr add $TINYDNS_ANO_IP/32 dev lo > /dev/null 2>&1 | |
624 ip addr add $GIT_IP/32 dev lo > /dev/null 2>&1 | |
625 | |
626 useradd Gdnscache | |
627 useradd Gdnslog | |
628 useradd Gtinydns | |
629 | |
630 dnscache-conf Gdnscache Gdnslog /services/dnscache | |
631 mv /services/dnscache/root/servers/@ /services/dnscache/root/servers/@.icann | |
632 echo $TINYDNS_ROOT_IP >/services/dnscache/root/servers/@ | |
633 echo 'nameserver 127.0.0.1' >/etc/resolv.conf | |
634 | |
635 | |
636 tinydns-conf Gtinydns Gdnslog /services/tinydns $TINYDNS_IP | |
637 ( | |
638 cd /services/tinydns/root | |
639 ./add-ns $NICK.ano $TINYDNS_IP | |
640 ./add-alias $GIT_DOMAIN $GIT_IP | |
641 ./add-alias $TINYDNS_ROOT_DOMAIN $TINYDNS_ROOT_IP | |
642 ./add-alias $TINYDNS_ANO_DOMAIN $TINYDNS_ANO_IP | |
643 make | |
644 ) | |
645 | |
646 tinydns-conf Gtinydns Gdnslog /services/tinydns-root $TINYDNS_ROOT_IP | |
647 ./scripts/nameserver_autogen/tinydns_root_datafile > /services/tinydns-root/root/data | |
648 ( cd /services/tinydns-root/root ; make ) | |
649 | |
650 tinydns-conf Gtinydns Gdnslog /services/tinydns-ano $TINYDNS_ANO_IP | |
651 ./scripts/nameserver_autogen/tinydns_tld_datafile > /services/tinydns-ano/root/data | |
652 ( cd /services/tinydns-ano/root ; make ) | |
653 | |
654 ( | |
655 cd / | |
656 ln -s /services/dnscache /service/dnscache | |
657 ln -s /services/tinydns /service/tinydns | |
658 ln -s /services/tinydns-ano /service/tinydns-ano | |
659 ln -s /services/tinydns-root /service/tinydns-root | |
660 cd /service ; sleep 5 ; svc -t dnscache tinydns tinydns-ano tinydns-root | |
661 ) | |
662 } | |
663 | |
664 INSTALL_DJBDNS(){ | |
665 echo -e '\nINSTALL DJBDNS:\n' | |
666 [[ $(echo X`which gcc`) == X ]] && echo ' fatal error: cannot find gcc' | |
667 [[ $(echo X`which gcc`) == X ]] && exit 1 | |
668 [[ $(echo X`which make`) == X ]] && echo ' fatal error: cannot find make' | |
669 [[ $(echo X`which make`) == X ]] && exit 1 | |
670 [[ $(echo X`which tcpserver`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp' | |
671 [[ $(echo X`which tcpserver`) == X ]] && exit 1 | |
672 [[ $(echo X`which svscanboot`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-daemontools' | |
673 [[ $(echo X`which svscanboot`) == X ]] && exit 1 | |
674 cd /usr/local/src | |
675 wget http://cr.yp.to/djbdns/djbdns-1.05.tar.gz | |
676 gunzip djbdns-1.05.tar | |
677 tar -xf djbdns-1.05.tar | |
678 cd djbdns-1.05 | |
679 echo gcc -O2 -include /usr/include/errno.h > conf-cc | |
680 make | |
681 make setup check | |
682 } | |
683 | |
684 UPDATE_DNS(){ | |
685 if [ -e /etc/peer2anonet/p2a.conf ]; then | |
686 source /etc/peer2anonet/p2a.conf | |
687 else | |
688 CONFIGURE | |
689 exit 0 | |
690 fi | |
691 | |
692 [[ $(echo X`which tcpserver`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp' | |
693 [[ $(echo X`which tcpserver`) == X ]] && exit 1 | |
694 [[ $(echo X`which svscanboot`) == X ]] && echo ' fatal error: needs ./contrib/peer2anonet/peer2anonet --install-daemontools' | |
695 [[ $(echo X`which svscanboot`) == X ]] && exit 1 | |
696 | |
697 if [ -e /services/tinydns-ano ]; then | |
698 ( | |
699 cd /services | |
700 echo "creating /etc/peer2anonet/tinydns-ano.tar backup" | |
701 tar cf /etc/peer2anonet/tinydns-ano.tar tinydns-ano | |
702 ) | |
703 fi | |
704 | |
705 echo -e '\nUPDATE DNS:\n' | |
706 ./scripts/nameserver_autogen/tinydns_tld_datafile > /services/tinydns-ano/root/data | |
707 ( cd /services/tinydns-ano/root ; make ) | |
708 | |
709 ( | |
710 cd /service | |
711 sleep 5 | |
712 svc -t dnscache tinydns tinydns-ano tinydns-root | |
713 ) | |
714 } | |
715 | |
716 INSTALL_NACL(){ | |
717 cd /usr/local/src | |
718 wget http://hyperelliptic.org/nacl/nacl-20110221.tar.bz2 | |
719 bunzip2 < nacl-20110221.tar.bz2 | tar -xf - | |
720 cd nacl-20110221 | |
721 ./do | |
722 } | |
723 | |
724 | |
725 if [ "$1" == '--configure' ]; then | |
726 CONFIGURE | |
727 elif [ "$1" == '--update' ]; then | |
728 UPDATE | |
729 elif [ "$1" == '--configure-peer' ]; then | |
730 CONFIGURE_PEER | |
731 UPDATE | |
732 elif [ "$1" == '--rm-peer' ]; then | |
733 RM_PEER | |
734 UPDATE | |
735 elif [ "$1" == '--install-daemontools' ]; then | |
736 INSTALL_DAEMONTOOLS | |
737 elif [ "$1" == '--install-ucspi-tcp' ]; then | |
738 INSTALL_UCSPI_TCP | |
739 elif [ "$1" == '--install-djbdns' ]; then | |
740 INSTALL_DJBDNS | |
741 elif [ "$1" == '--install-nacl' ]; then | |
742 INSTALL_NACL | |
743 elif [ "$1" == '--setup-qmail' ]; then | |
744 SETUP_QMAIL | |
745 elif [ "$1" == '--configure-dns' ]; then | |
746 CONFIGURE_DNS | |
747 elif [ "$1" == '--update-dns' ]; then | |
748 UPDATE_DNS | |
749 else | |
750 USAGE | |
751 fi |