From c00dc78f30a1655c3c3e1576a909794f8df3135f Mon Sep 17 00:00:00 2001 From: Peter Packult Date: Fri, 9 Sep 2011 20:15:42 +0200 Subject: [PATCH] Initial commit --- README.org | 2 ++ src/update_hacker_density | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 README.org create mode 100755 src/update_hacker_density diff --git a/README.org b/README.org new file mode 100644 index 0000000..fcfb030 --- /dev/null +++ b/README.org @@ -0,0 +1,2 @@ +Send MAC addrs of all current DHCP leases to . Transmit only if +the list changed since last transmission. diff --git a/src/update_hacker_density b/src/update_hacker_density new file mode 100755 index 0000000..6319f52 --- /dev/null +++ b/src/update_hacker_density @@ -0,0 +1,17 @@ +#!/bin/sh + +LeaseFile=/tmp/dhcp.leases +TmpFile=/tmp/hackers +StateFile=/tmp/hackers.md5 +Hash=md5sum + +awk '{ if ($1 > '$(date +%s)') print $2 }' < $LeaseFile > $TmpFile +OldHash=$(cat $StateFile 2>/dev/null) +NewHash=$($Hash $TmpFile | cut -f1 -d" ") +if [ "$OldHash" != "$NewHash" ]; then + # send new state, update local state only if transmission was succesful + ( echo Es sind $(wc -l <$TmpFile) Hacker im Space: + cat $TmpFile) \ + | nc -c feinsterfug.de 666 \ + && echo "$NewHash" > $StateFile +fi