From b56137d875f43026aeabcc4403252e5e7008b93a Mon Sep 17 00:00:00 2001 From: EUcancER Date: Tue, 23 Aug 2011 23:51:24 +0000 Subject: check-free-retiolum: fixed bug which produces wrong match --- retiolum/bin/check-free-retiolum-v4 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/check-free-retiolum-v4 b/retiolum/bin/check-free-retiolum-v4 index e9c6b3ce..3f0dbdf8 100755 --- a/retiolum/bin/check-free-retiolum-v4 +++ b/retiolum/bin/check-free-retiolum-v4 @@ -1,5 +1,4 @@ #! /bin/sh -set -x netname=retiolum myipv4=${1-10.7.7.-1} v4num=${myipv4##*.} @@ -10,12 +9,12 @@ then cd /etc/tinc/$netname/hosts printf "Check if ip is still free: " for i in `ls -1`; do - if grep $myipv4 $i &>/dev/null ;then + if grep -q -e $myipv4\$ $i ;then echo "Host IP already taken by $i! " exit 1 fi done - printf "Passed" + printf "Passed\n" else printf "you are made of stupid. bailing out\n" exit 1 -- cgit v1.2.3 From 229b805732cc34c30bb287aa750fbd14df94cc81 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 6 Sep 2011 23:00:03 +0200 Subject: //retiolum update-retiolum-hosts: cd //retiolum first This commit enables to call the script from everywhere...^_^ --- retiolum/bin/update-retiolum-hosts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'retiolum/bin') diff --git a/retiolum/bin/update-retiolum-hosts b/retiolum/bin/update-retiolum-hosts index 7b2fa0e5..1fecfe15 100755 --- a/retiolum/bin/update-retiolum-hosts +++ b/retiolum/bin/update-retiolum-hosts @@ -7,6 +7,9 @@ if test "${nosudo-false}" != true -a `id -u` != 0; then exit 23 # go to hell fi +# cd //retiolum +cd $(dirname $(readlink -f $0))/.. + mkdir -v -p /etc/tinc/retiolum/hosts cp -v -r hosts/* /etc/tinc/retiolum/hosts pkill -HUP tincd -- cgit v1.2.3 From 9d16807a67b40648095b15edf59fb7d601b9b079 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 15:55:05 +0200 Subject: //retiolum/bin/hosts: use BRE @sed --- retiolum/bin/hosts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/hosts b/retiolum/bin/hosts index 6939f52c..bd0c77dc 100755 --- a/retiolum/bin/hosts +++ b/retiolum/bin/hosts @@ -6,6 +6,8 @@ netname=${1-retiolum} cd /etc/tinc/$netname/hosts for i in `ls`; do - sed -rn 's|^ *Subnet *= *([^ /]*)(/[0-9]*)? *$|\1\t'$i' '$i'.'$netname'|p' $i + sed -n ' + s|^ *Subnet *= *\([^ /]*\)\(/[0-9]*\)\? *$|\1\t'$i' '$i'.'$netname'|p + ' $i done | sort -- cgit v1.2.3 From ee02a8c3dea925f568e58aebeb3e01a52ba21ef8 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 16:12:44 +0200 Subject: //retiolum/bin/ipv6: use BRE @sed --- retiolum/bin/ipv6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/ipv6 b/retiolum/bin/ipv6 index 65a1eaa1..34c6de71 100755 --- a/retiolum/bin/ipv6 +++ b/retiolum/bin/ipv6 @@ -13,7 +13,7 @@ if test `id -u` != 0; then fi file=/etc/tinc/retiolum/hosts/`hostname` -addr=`sed -rn 's|^Subnet *= *(42:[0-9A-Fa-f:]*/128)|\1|p' $file` +addr=`sed -n 's|^Subnet *= *\(42:[0-9A-Fa-f:]*/128\)|\1|p' $file` route=42::/16 start() { -- cgit v1.2.3 From bd44e393c7fcc5d2f92a99a2d6b52f1815ebdb84 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 16:44:11 +0200 Subject: //retiolum/bin/update_tinc_hosts: sed -i is evil, too --- retiolum/bin/update_tinc_hosts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/update_tinc_hosts b/retiolum/bin/update_tinc_hosts index fe0785e3..8cdc3beb 100755 --- a/retiolum/bin/update_tinc_hosts +++ b/retiolum/bin/update_tinc_hosts @@ -31,7 +31,10 @@ case "${*-I am made of stupid}" in $0 has magic || $0 print magic >> $hosts < /dev/null ;; ('destroy magic') - $0 has magic && sed -ie "/^$bs$/,/^$es$/d" $hosts + if $0 has magic; then + cache="`cat $hosts`" + echo "$cache" | sed "/^$bs$/,/^$es$/d" > $hosts + fi ;; ('has magic') grep -q "^$bs$" $hosts && grep -q "^$es$" $hosts -- cgit v1.2.3 From 1bc1b54e445f2d48d8f4c2080240a0f4e94d0c96 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 9 Sep 2011 16:45:54 +0200 Subject: //retiolum/bin/update_tinc_hosts: create magic implies [re]start --- retiolum/bin/update_tinc_hosts | 1 + 1 file changed, 1 insertion(+) (limited to 'retiolum/bin') diff --git a/retiolum/bin/update_tinc_hosts b/retiolum/bin/update_tinc_hosts index 8cdc3beb..86a28992 100755 --- a/retiolum/bin/update_tinc_hosts +++ b/retiolum/bin/update_tinc_hosts @@ -29,6 +29,7 @@ case "${*-I am made of stupid}" in ;; ('create magic') $0 has magic || $0 print magic >> $hosts < /dev/null + $0 start ;; ('destroy magic') if $0 has magic; then -- cgit v1.2.3