changeset 1028:8e301584fd93 draft

[contrib/peer2anonet/peer2anonet] /service/$peer/run == symlink /etc/peer2anonet/peers/$peer/run; /service/$peer/run will now read from /etc/peer2anonet/peers/$peer/<env files>; more simple toggle for REMOTE_FLOAT
author d3v11 <d3v11@d3v11.ano>
date Sat, 13 Oct 2012 23:03:00 +0000
parents 8d9b9994d29d
children eb46a7358fd0
files contrib/peer2anonet/peer2anonet
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/peer2anonet/peer2anonet	Sat Oct 13 14:52:15 2012 +0000
+++ b/contrib/peer2anonet/peer2anonet	Sat Oct 13 23:03:00 2012 +0000
@@ -236,16 +236,16 @@
 #
 #export REMOTE_FLOAT=1
 
-# comment if your peer has a dynamic IP
-#
-export REMOTE_ADDRESS=$REMOTEIP
-export REMOTE_PORT=$PEERPORT
+if [[ \$REMOTE_FLOAT != 1 ]]; then
+  export REMOTE_ADDRESS=\`cat /etc/peer2anonet/peers/$PEER/remote_ip\`
+  export REMOTE_PORT=\`cat /etc/peer2anonet/peers/$PEER/remote_port\`
+fi
 
 # not recommended to change these values
 #
-export LOCAL_PORT=$LOCALPORT
-export PRIVATE_KEY=$SECKEY
-export PUBLIC_KEY=$PUBKEY
+export LOCAL_PORT=\`cat /etc/peer2anonet/peers/$PEER/local_port\`
+export PRIVATE_KEY=\`cat /etc/peer2anonet/peers/$PEER/seckey\`
+export PUBLIC_KEY=\`cat /etc/peer2anonet/peers/$PEER/pubkey\`
 export TUN_MODE=1
 export INTERFACE=ppp-$PEER
 
@@ -261,23 +261,23 @@
 #route add \$REMOTE_ADDRESS gw \$DEFAULT_ROUTE
 
 ( sleep 5;
- ip addr add $P2A_IP peer $PEERIP/32 dev \$INTERFACE scope link
+ ip addr add $P2A_IP peer \`cat /etc/peer2anonet/peers/$PEER/peering_ip\`/32 dev \$INTERFACE scope link
  ip addr add $P2A_ROUTE/32 dev \$INTERFACE scope global
  ip link set dev \$INTERFACE up
 
 # comment the following ping line to remove pinghack. this is a
 # trick used to help bird connect.
 #
- ping -c 1 -I \$INTERFACE $PEERIP -r -w 5
+ ping -c 1 -I \$INTERFACE \`cat /etc/peer2anonet/peers/$PEER/peering_ip\` -r -w 5
 
 ) &
 exec /usr/sbin/quicktun.nacltai" > /etc/peer2anonet/peers/$PEER/run
-            cp /etc/peer2anonet/peers/$PEER/run /services/"$PEER"/run
         fi
-        chmod +x /services/"$PEER"/run
+        chmod +x /etc/peer2anonet/peers/"$PEER"/run
+        test -L /services/"$PEER"/run || rm -f /services/"$PEER"/run
+        test -L /services/"$PEER"/run || ln -s /etc/peer2anonet/peers/"$PEER"/run /services/"$PEER"/run
+        test -L "/service/$PEER" && svc -t "/service/$PEER"
         test -L "/service/$PEER" || ln -s "/services/$PEER" "/service/$PEER"
-        sleep 1
-        svc -d "/service/$PEER" ; svc -u "/service/$PEER"
     done
     test -L /service/bird || ln -s /services/bird /service/bird
     echo configure | birdc