From aea9d0216324198e7dc6b396f9be2194a5f72abb Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Oct 2011 12:56:10 +0200 Subject: //retiolum supernode-update-hosts-and-hup: init --- retiolum/bin/supernode-update-hosts-and-hup | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 retiolum/bin/supernode-update-hosts-and-hup (limited to 'retiolum/bin') diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup new file mode 100755 index 00000000..deff9f2f --- /dev/null +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -0,0 +1,33 @@ +#! /bin/sh +set -euf + +cd /etc/tinc/retiolum/hosts + +painload="$(dirname "$(readlink -f "$0")")/../.." + +temp1="`mktemp`" +temp2="`mktemp`" +trap "rm -f $temp1 $temp2" EXIT INT TERM + +old_commit="`cat .commit 2>/dev/null || :`" + +curl -fsS "https://github.com/krebscode/painload/tree/master/retiolum/hosts" | + "$painload/util/bin/hrefs" | + grep '^/krebscode/painload/blob/' | + grep -v "/blob/$old_commit/" >$temp1 + +new_commit=`sed 's|^/krebscode/painload/blob/\([^/]*\)/.*|\1|;q' $temp1` + +sed ' + s|^/krebscode/painload/blob/[^/]*/retiolum/hosts/\([^/]*\)$|\1| +' $temp1 > $temp2 + +xargs rm -v -f <$temp2 + +sed " + s|^.*$|https://raw.github.com/krebscode/painload/$new_commit/retiolum/hosts/&| +" $temp2 > $temp1 + +wget -qi- < $temp1 + +echo $new_commit > .commit -- cgit v1.2.3 From 9c2721f58f6ec9c271dd16f2bf0ddc054f24f403 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Oct 2011 12:58:20 +0200 Subject: //retiolum supernode-...: do the HUP! --- retiolum/bin/supernode-update-hosts-and-hup | 2 ++ 1 file changed, 2 insertions(+) (limited to 'retiolum/bin') diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup index deff9f2f..b1ce3489 100755 --- a/retiolum/bin/supernode-update-hosts-and-hup +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -31,3 +31,5 @@ sed " wget -qi- < $temp1 echo $new_commit > .commit + +pkill -HUP tincd -- cgit v1.2.3 From 8b1827f42d3d8a967b9a385bbb048835e1792872 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Oct 2011 13:00:44 +0200 Subject: //retiolum super-...: inline hrefs --- retiolum/bin/supernode-update-hosts-and-hup | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup index b1ce3489..221a7538 100755 --- a/retiolum/bin/supernode-update-hosts-and-hup +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -3,16 +3,18 @@ set -euf cd /etc/tinc/retiolum/hosts -painload="$(dirname "$(readlink -f "$0")")/../.." - temp1="`mktemp`" temp2="`mktemp`" trap "rm -f $temp1 $temp2" EXIT INT TERM old_commit="`cat .commit 2>/dev/null || :`" +_hrefs() { + sed -n 's/href="\([^"]\+\)"/\n&\n/gp' | + sed -n 's/^href="\([^"]\+\)"$/\1/p'; } + curl -fsS "https://github.com/krebscode/painload/tree/master/retiolum/hosts" | - "$painload/util/bin/hrefs" | + _hrefs | grep '^/krebscode/painload/blob/' | grep -v "/blob/$old_commit/" >$temp1 -- cgit v1.2.3 From 979a90b5e238d3bdfea16599d93128cfd1475bc4 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Oct 2011 13:05:07 +0200 Subject: //retiolum supernode-...: add little doc --- retiolum/bin/supernode-update-hosts-and-hup | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'retiolum/bin') diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup index 221a7538..bfba6409 100755 --- a/retiolum/bin/supernode-update-hosts-and-hup +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -1,4 +1,8 @@ #! /bin/sh +# +# @oxberg we do put this into crontab: +# * * * * * /supernode-update-hosts-and-hup +# set -euf cd /etc/tinc/retiolum/hosts @@ -13,25 +17,27 @@ _hrefs() { sed -n 's/href="\([^"]\+\)"/\n&\n/gp' | sed -n 's/^href="\([^"]\+\)"$/\1/p'; } -curl -fsS "https://github.com/krebscode/painload/tree/master/retiolum/hosts" | +if curl -fsS \ + "https://github.com/krebscode/painload/tree/master/retiolum/hosts" | _hrefs | grep '^/krebscode/painload/blob/' | grep -v "/blob/$old_commit/" >$temp1 -new_commit=`sed 's|^/krebscode/painload/blob/\([^/]*\)/.*|\1|;q' $temp1` + new_commit=`sed 's|^/krebscode/painload/blob/\([^/]*\)/.*|\1|;q' $temp1` -sed ' - s|^/krebscode/painload/blob/[^/]*/retiolum/hosts/\([^/]*\)$|\1| -' $temp1 > $temp2 + sed ' + s|^/krebscode/painload/blob/[^/]*/retiolum/hosts/\([^/]*\)$|\1| + ' $temp1 > $temp2 -xargs rm -v -f <$temp2 + xargs rm -v -f <$temp2 -sed " - s|^.*$|https://raw.github.com/krebscode/painload/$new_commit/retiolum/hosts/&| -" $temp2 > $temp1 + sed " + s|^.*$|https://raw.github.com/krebscode/painload/$new_commit/retiolum/hosts/&| + " $temp2 > $temp1 -wget -qi- < $temp1 + wget -qi- < $temp1 -echo $new_commit > .commit + echo $new_commit > .commit -pkill -HUP tincd + pkill -HUP tincd +fi -- cgit v1.2.3 From 1cff2a9d548336ddcd8a2d732ed2cd348c8e6b79 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Oct 2011 13:08:29 +0200 Subject: //retiolum supernode-...: fix typo --- retiolum/bin/supernode-update-hosts-and-hup | 1 + 1 file changed, 1 insertion(+) (limited to 'retiolum/bin') diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup index bfba6409..b6b03c69 100755 --- a/retiolum/bin/supernode-update-hosts-and-hup +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -22,6 +22,7 @@ if curl -fsS \ _hrefs | grep '^/krebscode/painload/blob/' | grep -v "/blob/$old_commit/" >$temp1 +then new_commit=`sed 's|^/krebscode/painload/blob/\([^/]*\)/.*|\1|;q' $temp1` -- cgit v1.2.3