mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-14 14:11:26 -07:00
Coderabbit nitpicks.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# NetAlertX
|
||||
@@ -14,13 +15,35 @@
|
||||
# /usr/share/arp-scan
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
TEMP_FILE="/services/run/tmp/ieee-oui.txt.tmp"
|
||||
OUTPUT_FILE="/services/run/tmp/ieee-oui.txt"
|
||||
|
||||
# Download the file using wget to stdout and process it
|
||||
wget -q "https://standards-oui.ieee.org/oui/oui.txt" -O /dev/stdout | \
|
||||
sed -E 's/ *\(base 16\)//' | \
|
||||
awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' | \
|
||||
sort | \
|
||||
awk '{$1=$1; print}' | \
|
||||
sort -u | \
|
||||
awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' \
|
||||
if ! wget --timeout=30 --tries=3 "https://standards-oui.ieee.org/oui/oui.txt" -O /dev/stdout | \
|
||||
sed -E 's/ *\(base 16\)//' | \
|
||||
awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' | \
|
||||
sort | \
|
||||
awk '{$1=$1; print}' | \
|
||||
sort -u | \
|
||||
awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' \
|
||||
> "${TEMP_FILE}"; then
|
||||
echo "ERROR: Failed to download or process OUI data" >&2
|
||||
rm -f "${TEMP_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate we got actual content (should have hundreds of thousands of lines)
|
||||
if [ ! -s "${TEMP_FILE}" ] || [ "$(wc -l < "${TEMP_FILE}")" -lt 1000 ]; then
|
||||
echo "ERROR: OUI data appears invalid or incomplete" >&2
|
||||
rm -f "${TEMP_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Atomic replacement
|
||||
mv "${TEMP_FILE}" "${OUTPUT_FILE}"
|
||||
echo "Successfully updated IEEE OUI database ($(wc -l < "${OUTPUT_FILE}") entries)"
|
||||
> /services/run/tmp/ieee-oui.txt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user