repo: resdb
action: commit
revision: 
path_from: 
revision_from: 8307feb012e94c2a4b43b9a5b42dacedab2725ca:
path_to: 
revision_to: 
git.thebackupbox.net
resdb
git clone git://git.thebackupbox.net/resdb
commit 8307feb012e94c2a4b43b9a5b42dacedab2725ca
Author: d3v11 
Date:   Sat Nov 26 05:16:10 2011 +0000

    massive update to peer2anonet, here's hoping i didn't fuck something
    up ;-)

diff --git a/contrib/peer2anonet/DEBIAN/configure b/contrib/peer2anonet/DEBIAN/configure
deleted file mode 100755
index 6a01c74ac9b6087fffbb249cfae227b3c530e8ff..0000000000000000000000000000000000000000
--- a/contrib/peer2anonet/DEBIAN/configure
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-read -p "Enter your anonet network: " P2A_NET
-read -p "Enter your anonet router: " P2A_ROUTE
-read -p "Enter your anonet asn: " P2A_ASN
-read -p "Enter your anonet ip: " P2A_IP
-
-echo "P2A_NET=\"$P2A_NET\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf
-echo "P2A_ROUTE=\"$P2A_ROUTE\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf
-echo "P2A_ASN=\"$P2A_ASN\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf
-echo "P2A_IP=\"$P2A_IP\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf
diff --git a/contrib/peer2anonet/DEBIAN/control b/contrib/peer2anonet/DEBIAN/control
deleted file mode 100644
index 903b29e5313c46fbf318899db28cc9d028c0e7c7..0000000000000000000000000000000000000000
--- a/contrib/peer2anonet/DEBIAN/control
+++ /dev/null
@@ -1,12 +0,0 @@
-Source: peer2anonet
-Priority: optional
-Maintainer: d3v11
-Version: 1.0-0
-Package: peer2anonet
-Architecture: all
-Depends: bash(>= 4.1)
-Description: peer2anonet 1.0-0
- peer2anonet is an autoconfiguration utility to easily establish a
- peering session with BGP on AnoNet2.
-
-
diff --git a/contrib/peer2anonet/README b/contrib/peer2anonet/README
index 8b8eacf02d4d656f1621ff373c824b27f5ebfbd1..
index ..1b300b4b73c85dbaad46ab794b06d8b473cb0977 100644
--- a/contrib/peer2anonet/README
+++ b/contrib/peer2anonet/README
@@ -1,64 +1,105 @@
 DESCRIPTION:
-     peer2anonet is an autoconfiguration utility to easily establish a
-     peering session with BGP on AnoNet2.
+
+    peer2anonet is an autoconfiguration utility for setting
+    up core services on AnoNet2. Enjoy :-).

 DEPENDS ON:
-      quicktun, bird, daemontools(non-deb), bash

-USAGE:
+    quicktun, bird, daemontools(non-deb), bash
+
+AUTHOR:
+
+    d3v11 from www.d3v11.ano somtimes, maybe, dunno.
+
+    REPORT BULLSHIT TO:

-    --configure             generate a new local configuration and exit
+        IRC:
+        
+            /relayhell/d3v11

-    --update                regenerate peer configurations
+        EMAIL:
+        
+            d3v11@d3v11.ano

-    --configure-peer        generate a new peer configuration and update
+USAGE:
+
+    ./contrib/peer2anonet/peer2anonet --configure             generate a new local configuration and exit

-    --rm-peer               remove a peer configuration and update
+    ./contrib/peer2anonet/peer2anonet --update                regenerate peer configurations

-    --install-daemontools   installs daemontools
+    ./contrib/peer2anonet/peer2anonet --configure-peer        generate a new peer configuration and update

-    --install-ucspi-tcp     installs ucspi-tcp
+    ./contrib/peer2anonet/peer2anonet --rm-peer               remove a peer configuration and update

-    --install-djbdns        installs djbdns
+    ./contrib/peer2anonet/peer2anonet --install-daemontools   installs daemontools

-NOTES:
+    ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp     installs ucspi-tcp

-    KEY PAIRS:
+    ./contrib/peer2anonet/peer2anonet --install-djbdns        installs djbdns

-        before running peer2anonet to configure peers you can use
-        quicktun to generate keypairs:
+    ./contrib/peer2anonet/peer2anonet --configure-dns         configures dnscache and tinydns zones

-            quicktun.keypair
index 98fef00460988ef82a6c413c870ea5694b545c7e..
index ..a2a9906c19b1c142d289138d554a49540bb49c01 100755
--- a/contrib/peer2anonet/peer2anonet
+++ b/contrib/peer2anonet/peer2anonet
@@ -1,22 +1,26 @@
 #!/bin/bash
 if [[ $(id -u) != 0 ]]; then
-    echo "error: root privileges required."
+    echo "peer2anonet: root privileges required."
     exit 1
 fi

 if [ -e /services/bird ]; then
-    [ -e /etc/peer2anonet/bird.tar ] || (cd /services ; tar /etc/peer2anonet/bird.tar bird)
+    [ -e /etc/peer2anonet/bird.tar ] || ( cd /services ; tar cf /etc/peer2anonet/bird.tar bird )
 fi

+[ -e contrib/peer2anonet/peer2anonet ] || echo "peer2anonet: not in \$RESDB_ROOT"
+[ -e contrib/peer2anonet/peer2anonet ] || exit 1
+
 USAGE(){
     echo -e '\npeer2anonet:'
-    echo -e '\n    --configure             generate a new local configuration and exit'
-    echo -e '\n    --update                regenerate peer configurations'
-    echo -e '\n    --configure-peer        generate a new peer configuration and update'
-    echo -e '\n    --rm-peer               remove a peer configuration and update'
-    echo -e '\n    --install-daemontools   installs daemontools'
-    echo -e '\n    --install-ucspi-tcp     installs ucspi-tcp'
-    echo -e '\n    --install-djbdns        installs djbdns\n'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --configure             generate a new local configuration and exit'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --update                regenerate peer configurations'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --configure-peer        generate a new peer configuration and update'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --rm-peer               remove a peer configuration and update'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --install-daemontools   installs daemontools'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --install-ucspi-tcp     installs ucspi-tcp'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --install-djbdns        installs djbdns'
+    echo -e '\n    ./contrib/peer2anonet/peer2anonet --configure-dns         configures dnscache and tinydns zones\n'
     exit 0
     }

@@ -44,6 +48,10 @@ CONFIGURE(){
     echo "P2A_IP=\"$P2A_IP\"">>/etc/peer2anonet/p2a.conf
     echo "P2A_ASN=\"$P2A_ASN\"">>/etc/peer2anonet/p2a.conf
     echo -e '\npeer2anonet: configured\n'
+    NICK=`cat conf/git_name`
+    ./scripts/add_as $P2A_ASN $NICK
+    ./scripts/add_ip $P2A_NET/24 $NICK
+    ./scripts/add_dom $NICK.ano $NICK a.ns.$NICK.ano/`cat db/dom/ano/$NICK/ns/a.ns.$NICK.ano`
     exit 0
     }

@@ -247,6 +255,7 @@ CONFIGURE_PEER(){
     read -p "   Enter your peer's asn: " PEERASN
     read -p "   Enter your peer's public key: " PUBKEY
     read -p "   Enter your private key: " SECKEY
+    [ -e /etc/peer2anonet/peers/"$PEER" ] && rm -r /etc/peer2anonet/peers/"$PEER"
     mkdir -p /etc/peer2anonet/peers/"$PEER"
     echo $REMOTEIP >/etc/peer2anonet/peers/"$PEER"/remote_ip
     echo $PEERIP >/etc/peer2anonet/peers/"$PEER"/peering_ip
@@ -272,10 +281,13 @@ RM_PEER(){
     }

 INSTALL_DAEMONTOOLS(){
+    echo -e '\nINSTALL DAEMONTOOLS:\n'
     [[ $(echo X`which gcc`) == X ]] && echo '   error: cannot find gcc'
     [[ $(echo X`which gcc`) == X ]] && exit 1
     [[ $(echo X`which make`) == X ]] && echo '   error: cannot find make'
     [[ $(echo X`which make`) == X ]] && exit 1
+    [[ $(echo X`which csh`) == X ]] && echo '   error: cannot find csh'
+    [[ $(echo X`which csh`) == X ]] && exit 1
     mkdir -p /package
     chmod 1755 /package
     cd /package
@@ -286,9 +298,13 @@ INSTALL_DAEMONTOOLS(){
     cd admin/daemontools-0.76
     sed -i 's/gcc/gcc -include errno.h/g' src/conf-cc
     package/install
+    cp /etc/rc.local /etc/peer2anonet/rc.local.backup
+    sed -i "s/exit 0/csh -cf \'\/command\/svscanboot \&\'/" /etc/rc.local
+    chmod +x /etc/rc.local
     }

 INSTALL_UCSPI_TCP(){
+    echo -e '\nINSTALL UCSPI-TCP:\n'
     [[ $(echo X`which gcc`) == X ]] && echo '   error: cannot find gcc'
     [[ $(echo X`which gcc`) == X ]] && exit 1
     [[ $(echo X`which make`) == X ]] && echo '   error: cannot find make'
@@ -304,6 +320,7 @@ INSTALL_UCSPI_TCP(){
     }

 INSTALL_DJBDNS(){
+    echo -e '\nINSTALL DJBDNS:\n'
     [[ $(echo X`which gcc`) == X ]] && echo '   error: cannot find gcc'
     [[ $(echo X`which gcc`) == X ]] && exit 1
     [[ $(echo X`which make`) == X ]] && echo '   error: cannot find make'
@@ -318,6 +335,59 @@ INSTALL_DJBDNS(){
     make setup check
     }

+CONFIGURE_DNS(){
+    echo -e '\nCONFIGURE DNS:\n'
+    NICK=`cat conf/git_name`
+    TINYDNS_ROOT_IP=`cat conf/tinydns__rootsrvrip`
+    TINYDNS_ROOT_DOMAIN=`cat conf/tinydns__rootsrvrname`
+    TINYDNS_ANO_IP=`cat conf/tinydns__tldsrvrip`
+    TINYDNS_ANO_DOMAIN=`cat conf/tinydns__tldsrvrname`
+    TINYDNS_IP=`cat db/dom/ano/$NICK/ns/a.ns.$NICK.ano`
+    TINYDNS_DOMAIN="a.ns.$NICK.ano"
+    GIT_IP=`cat conf/gitd_ip`
+    GIT_DOMAIN="git.$NICK.ano"
+
+    ip addr add $TINYDNS_ROOT_IP/32 dev lo &
+    ip addr add $TINYDNS_IP/32 dev lo &
+    ip addr add $TINYDNS_ANO_IP/32 dev lo &
+    ip addr add $GIT_IP/32 dev lo &
+
+    echo "ip addr add $TINYDNS_ROOT_IP/32 dev lo &" >> /etc/rc.local
+    echo "ip addr add $TINYDNS_IP/32 dev lo &" >> /etc/rc.local
+    echo "ip addr add $TINYDNS_ANO_IP/32 dev lo &" >> /etc/rc.local
+    echo "ip addr add $GIT_IP/32 dev lo &" >> /etc/rc.local
+
+    useradd Gdnscache
+    useradd Gdnslog
+    useradd Gtinydns
+ 
+    dnscache-conf Gdnscache Gdnslog /services/dnscache
+    mv /services/dnscache/root/servers/@ /services/dnscache/root/servers/@.icann
+    echo $TINYDNS_ROOT_IP >/services/dnscache/root/servers/@
+    echo 'nameserver 127.0.0.1' >/etc/resolv.conf
+    ( cd / ; ln -s /services/dnscache /service/dnscache )
+
+    tinydns-conf Gtinydns Gdnslog /services/tinydns $TINYDNS_IP
+    ( cd / ; ln -s /services/tinydns /service/tinydns )
+    ( cd /service/tinydns/root ; ./add-ns $TINYDNS_DOMAIN $TINYDNS_IP )
+    ( cd /service/tinydns/root ; ./add-alias $GIT_DOMAIN $GIT_IP )
+    ( cd /service/tinydns/root ; ./add-alias $TINYDNS_ANO_IP $TINYDNS_ROOT_IP )
+    ( cd /service/tinydns/root ; ./add-alias $TINYDNS_ANO_DOMAIN $TINYDNS_ANO_IP )
+    ( cd /service/tinydns/root ; make )
+
+    tinydns-conf Gtinydns Gdnslog /services/tinydns-root $TINYDNS_ROOT_IP
+    ( cd / ; ln -s /services/tinydns-root /service/tinydns-root )
+    ./scripts/nameserver_autogen/tinydns_root_datafile > /service/tinydns-root/root/data
+    ( cd /service/tinydns-root/root ; make )
+
+    tinydns-conf Gtinydns Gdnslog /services/tinydns-ano $TINYDNS_ANO_IP
+    ( cd / ; ln -s /services/tinydns-ano /service/tinydns-ano )
+    ./scripts/nameserver_autogen/tinydns_tld_datafile > /service/tinydns-ano/root/data
+    ( cd /service/tinydns-ano/root ; make )
+
+    ( cd /service ; svc -t dnscache tinydns* )    
+    }
+

 if [ "$1" == '--configure' ]; then
     CONFIGURE
@@ -335,6 +405,8 @@ elif [ "$1" == '--install-ucspi-tcp' ]; then
     INSTALL_UCSPI_TCP
 elif [ "$1" == '--install-djbdns' ]; then
     INSTALL_DJBDNS
+elif [ "$1" == '--configure-dns' ]; then
+    CONFIGURE_DNS
 else
     USAGE
 fi

-----END OF PAGE-----