Skip to content
Snippets Groups Projects
Verified Commit f567ced5 authored by David Beniamine's avatar David Beniamine
Browse files

Avoid duplicates

parent 6dad5b84
Branches uploads-file
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
BASE_MACS="6c:4b:90 a4:1f:72 78:45:c4 64:00:6a b0:83:fe d4:be:d9 00:23:24" 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" arg="c8:1f:66"
registry="/etc/registry/hosts"
cp $registry $registry.bak
for mac in $BASE_MACS for mac in $BASE_MACS
do do
arg="$arg\| $mac" arg="$arg\| $mac"
...@@ -10,12 +12,15 @@ MACS="" ...@@ -10,12 +12,15 @@ MACS=""
for line in $(grep "$arg" /var/lib/dhcp/dhcpd.leases | sort -u) for line in $(grep "$arg" /var/lib/dhcp/dhcpd.leases | sort -u)
do do
if [ "$line" != "hardware" ] && [ "$line" != "ethernet" ] if [ "$line" != "hardware" ] && [ "$line" != "ethernet" ]
then
if [ -z "$(grep $line $registry)" ]
then then
MACS="$MACS $(echo $line | sed 's/;$//g')" MACS="$MACS $(echo $line | sed 's/;$//g')"
fi fi
fi
done done
for mac in $MACS for mac in $MACS
do do
echo "20191025 $mac inconnuAutoGen" >> /etc/registry/hosts echo "20191025 $mac inconnuAutoGen" >> $registry
done done
systemctl restart registry wakeonlan systemctl restart registry wakeonlan
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment