Added script for appending ips to blocklist
parent
81364e9bfe
commit
d455d62dbf
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail;
|
||||
|
||||
LIST_FILE="$(dirname "$0")/ipv4.txt";
|
||||
TMP_FILE="$(mktemp)";
|
||||
|
||||
IP_REGEX='(?<!\d)\d+(\.\d+){3}(?!\d)';
|
||||
|
||||
cat "$LIST_FILE" "$@" |
|
||||
grep --only-matching --perl-regexp "$IP_REGEX" |
|
||||
sort --version-sort |
|
||||
uniq > "$TMP_FILE";
|
||||
|
||||
echo "$TMP_FILE";
|
||||
if diff "$LIST_FILE" "$TMP_FILE"; then
|
||||
echo "No differences found!";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
echo "Press enter to approve changes, ^C to abort";
|
||||
read;
|
||||
|
||||
mv "$TMP_FILE" "$LIST_FILE";
|
Loading…
Reference in New Issue