diff options
author | krebs <krebs@fuerkrebs> | 2011-10-13 13:20:02 -0400 |
---|---|---|
committer | krebs <krebs@fuerkrebs> | 2011-10-13 13:20:02 -0400 |
commit | 6caf0d1c502ba9eb6d41aa9a80cb8a350164846d (patch) | |
tree | 28237066c93656fe75b2fcc7fb1eec0a2b800888 /retiolum/bin | |
parent | fa7213811c2c77b9f2097c11c8a072265d8a3ac2 (diff) | |
parent | 1cff2a9d548336ddcd8a2d732ed2cd348c8e6b79 (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/bin')
-rwxr-xr-x | retiolum/bin/supernode-update-hosts-and-hup | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/retiolum/bin/supernode-update-hosts-and-hup b/retiolum/bin/supernode-update-hosts-and-hup new file mode 100755 index 00000000..b6b03c69 --- /dev/null +++ b/retiolum/bin/supernode-update-hosts-and-hup @@ -0,0 +1,44 @@ +#! /bin/sh +# +# @oxberg we do put this into crontab: +# * * * * * /supernode-update-hosts-and-hup +# +set -euf + +cd /etc/tinc/retiolum/hosts + +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'; } + +if curl -fsS \ + "https://github.com/krebscode/painload/tree/master/retiolum/hosts" | + _hrefs | + grep '^/krebscode/painload/blob/' | + grep -v "/blob/$old_commit/" >$temp1 +then + + 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 + + pkill -HUP tincd +fi |