Created
April 24, 2011 20:54
-
-
Save 4z3/939871 to your computer and use it in GitHub Desktop.
scrape retiolum's subnet list from syslog[-ng]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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