Skip to content

Instantly share code, notes, and snippets.

@4z3
Created April 24, 2011 20:54
Show Gist options
  • Save 4z3/939871 to your computer and use it in GitHub Desktop.
Save 4z3/939871 to your computer and use it in GitHub Desktop.
scrape retiolum's subnet list from syslog[-ng]
#! /bin/sh
set -euf
tempfile=`tempfile`
trap "rm $tempfile" EXIT
inotail -n 0 -f /var/log/syslog.log |
sed -rn '
/tinc\.retiolum/!b
/.*: Subnet list:$/,/.*: End of subnet list\.$/{
s/.*: ([^:]*)$/\1/p
}
/.*: End of subnet list\.$/q
' >$tempfile &
that=$!
retiolum --kill=USR2
retiolum --kill=USR2 # yes, we have to do it twice--deal with it^_^
wait $that
sed -rn 's:^([0-9.]*)/32#10 owner ([a-z_]*)$:\1\t\2:p' $tempfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment