summaryrefslogtreecommitdiffstats
path: root/retiolum/bin
diff options
context:
space:
mode:
Diffstat (limited to 'retiolum/bin')
-rwxr-xr-xretiolum/bin/check-free-retiolum-v45
-rwxr-xr-xretiolum/bin/hosts4
-rwxr-xr-xretiolum/bin/ipv62
-rwxr-xr-xretiolum/bin/update-retiolum-hosts3
-rwxr-xr-xretiolum/bin/update_tinc_hosts6
5 files changed, 14 insertions, 6 deletions
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
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
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() {
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
diff --git a/retiolum/bin/update_tinc_hosts b/retiolum/bin/update_tinc_hosts
index fe0785e3..86a28992 100755
--- a/retiolum/bin/update_tinc_hosts
+++ b/retiolum/bin/update_tinc_hosts
@@ -29,9 +29,13 @@ case "${*-I am made of stupid}" in
;;
('create magic')
$0 has magic || $0 print magic >> $hosts < /dev/null
+ $0 start
;;
('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