summaryrefslogtreecommitdiffstats
path: root/retiolum
diff options
context:
space:
mode:
authortv <tv@iiso>2011-10-12 12:56:10 +0200
committertv <tv@iiso>2011-10-12 12:56:10 +0200
commitaea9d0216324198e7dc6b396f9be2194a5f72abb (patch)
treec454700f33498160182680b9b1ab4ca08490d70c /retiolum
parente8923cc1ce69716b192e317cb4d5b9e8f0de4e68 (diff)
//retiolum supernode-update-hosts-and-hup: init
Diffstat (limited to 'retiolum')
-rwxr-xr-xretiolum/bin/supernode-update-hosts-and-hup33
1 files changed, 33 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..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