From 056f1f40257c3a592ee6a7f6e7c4a44ac0938b2c Mon Sep 17 00:00:00 2001 From: reddog Date: Mon, 6 Jun 2011 16:16:17 +0000 Subject: [PATCH] tincstart.sh shouldn't write in flash on every refresh. --- root_file_system/default/etc/tincstart.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/root_file_system/default/etc/tincstart.sh b/root_file_system/default/etc/tincstart.sh index 6c57a898..5ecf1bbb 100755 --- a/root_file_system/default/etc/tincstart.sh +++ b/root_file_system/default/etc/tincstart.sh @@ -39,11 +39,13 @@ fi if [ ! -d /etc/tinc/$project ] then mkdir /etc/tinc/$project + ln -s /tmp/tinc_$project.conf /etc/tinc/$project/tinc.conf - echo -n -e "\n\n" | tincd --pidfile=/etc/tinc/$project/tinc.pid -n $project -K - kill -HUP $(cat /etc/tinc/$project/tinc.pid) + echo -n -e "\n\n" | tincd --pidfile=/var/run/tinc_$project.pid -n $project -K + kill -HUP $(cat /var/run/tinc_$project.pid) sleep 3 - mkdir /etc/tinc/$project/hosts + mkdir /tmp/tinc_${project}_hosts + ln -s /tmp/tinc_${project}_hosts /etc/tinc/$project/hosts echo "ifconfig \$INTERFACE up" > /etc/tinc/$project/tinc-up if [ "$SERVER" == "no" ] then @@ -52,6 +54,11 @@ then chmod +x /etc/tinc/$project/tinc-up fi +if [ ! -d /tmp/tinc_${project}_hosts ] +then + mkdir /tmp/tinc_${project}_hosts +fi + pubkey=$(for line in $(cat /etc/tinc/$project/rsa_key.pub | sed -e 's/$/%0a/g' | sed -e 's/+/%2b/g' | sed -e 's/ /%20/g'); do echo -n $line; done) port=666 @@ -77,18 +84,18 @@ fi # fire up if [ "$(ps aux | grep tincd | grep -v grep)" == "" ] then - tincd -c /etc/tinc/$project --pidfile=/etc/tinc/$project/tinc.pid --logfile=/var/log/tinc.log $DEBUG + tincd -c /etc/tinc/$project --pidfile=/var/run/tinc_$project.pid --logfile=/var/log/tinc_$project.log $DEBUG # sleep 1 # brctl addif br-mesh tap0 fi # register -wget -T15 "http://mastersword.de/~reddog/tinc/?name=$hostname&port=$port&key=$pubkey" -O /etc/tinc/$project/output +wget -T15 "http://mastersword.de/~reddog/tinc/?name=$hostname&port=$port&key=$pubkey" -O /tmp/tinc_${project}_output -filenames=$(cat /etc/tinc/$project/output| grep ^#### | sed -e 's/^####//' | sed -e 's/.conf//g') +filenames=$(cat /tmp/tinc_${project}_output| grep ^#### | sed -e 's/^####//' | sed -e 's/.conf//g') for file in $filenames do -grep -A100 $file /etc/tinc/$project/output | grep -v $file | grep -m1 ^### -B100 | grep -v ^### > /etc/tinc/$project/hosts/$file.new +grep -A100 $file /tmp/tinc_${project}_output | grep -v $file | grep -m1 ^### -B100 | grep -v ^### > /etc/tinc/$project/hosts/$file.new if [ "$(diff /etc/tinc/$project/hosts/$file.new /etc/tinc/$project/hosts/$file 2>&1)" == "" ] then /bin/rm /etc/tinc/$project/hosts/$file.new @@ -108,7 +115,7 @@ cat /etc/tinc/$project/rsa_key.pub >> /etc/tinc/$project/hosts/$hostname fi #reload -kill -HUP $(cat /etc/tinc/$project/tinc.pid) +kill -HUP $(cat /var/run/tinc_$project.pid) else echo "Der Router kann keine Verbindung zum Tincserver aufbauen"