From 1de1a4df71bbf2a0c811c34abe60c45f517fc1fe Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Tue, 29 Oct 2019 12:08:33 +0100 Subject: [PATCH] Fix host regeneration --- regenerate_hosts.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/regenerate_hosts.sh b/regenerate_hosts.sh index 5a68ac2..1d3060c 100755 --- a/regenerate_hosts.sh +++ b/regenerate_hosts.sh @@ -2,20 +2,21 @@ BASE_MACS="6c:4b:90 a4:1f:72 78:45:c4 64:00:6a b0:83:fe d4:be:d9 00:23:24" arg="c8:1f:66" registry="/etc/registry/hosts" -cp $registry "$registry_$(date '+%Y%m%d_%H%M')" +cp -v $registry "$registry-$(date '+%Y%m%d_%H%M')" for mac in $BASE_MACS do arg="$arg\| $mac" done -echo grep "$arg" /var/lib/dhcp/dhcpd.leases +#echo grep "$arg" /var/lib/dhcp/dhcpd.leases MACS="" for line in $(grep "$arg" /var/lib/dhcp/dhcpd.leases | sort -u) do if [ "$line" != "hardware" ] && [ "$line" != "ethernet" ] then - if [ -z "$(grep $line $registry)" ] + mac=$(echo $line | sed 's/;$//g') + if [ -z "$(grep $mac $registry)" ] then - MACS="$MACS $(echo $line | sed 's/;$//g')" + MACS="$MACS $mac" fi fi done -- GitLab