/usr/bin/update-oui is in ieee-data 20150531.1~deb8u2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #!/bin/sh
# Copyright © 2013 Filippo Giunchedi <filippo@debian.org>
# Copyright © 2014 Luciano Bello <luciano@debian.org>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar.
# See the LICENSE file for more details.
BASEDIR=${BASEDIR:-/var/lib/ieee-data/}
RUN_PARSERS=${RUN_PARSERS:-1}
OLD="5"
FORCE=false
QUIET=false
set -e
ouiurl="http://standards.ieee.org/regauth/oui/oui.txt"
oui28url="http://standards.ieee.org/develop/regauth/oui28/mam.txt"
oui36url="http://standards.ieee.org/develop/regauth/oui36/oui36.txt"
iaburl="http://standards.ieee.org/regauth/oui/iab.txt"
tmpf=$(tempfile --mode=0644)
Die () {
$QUIET || echo $1
exit 1
}
testFileOUI () {
LOOKOUI='OUI.*\s*Organization\s*.*\s*Organization\s*Address'
head -n 6 $1 | tr -d '\n' | grep -qe "$LOOKOUI" || ( rm $1 && Die "The downloaded oui.txt looks corrupted." )
}
goAndGet () {
$QUIET || echo "Downloading $1 to $BASEDIR/$2"
$dler $1 > $tmpf || { Die "$dler $1 exit with $?";}
testFileOUI $tmpf
mv -f $tmpf $BASEDIR/$2
}
while getopts ":fq" opt; do
case $opt in
f)
FORCE=true
;;
q)
QUIET=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
dler=""
[ -x $(which curl) ] && dler="curl"
[ -x $(which lwp-request) ] && dler="lwp-request -m GET"
[ -x $(which wget) ] && dler="wget -q -O-"
if [ -z "$dler" ]; then
Die "Unable to find a suitable downloader, please install wget or curl or libwww-perl"
fi
cd $BASEDIR || { Die "can't cd to $BASEDIR"; }
LASTUPDATE=$(cat $BASEDIR/.lastupdate)
OLD_SECONDS=$(expr $OLD \* 86400)
CURRENT=$(date +%s)
AGE=$(expr $CURRENT - $LASTUPDATE)
if [ $FORCE = false -a $AGE -le $OLD_SECONDS ]; then
Die "The files are kinda new yet (less than $OLD days old)"
fi
goAndGet $ouiurl oui.txt
goAndGet $iaburl iab.txt
goAndGet $oui28url mam.txt
goAndGet $oui36url oui36.txt
rm $BASEDIR/.lastupdate
echo $CURRENT > $BASEDIR/.lastupdate
if [ -x $(which run-parts) ] && [ -d update.d ] && [ $RUN_PARSERS -ne 0 ]; then
$QUIET || echo "Running parsers from $BASEDIR/update.d"
run-parts -a "$BASEDIR" -a oui.txt update.d/
run-parts -a "$BASEDIR" -a iab.txt update.d/
fi
|