Server IP : 85.214.239.14 / Your IP : 18.224.57.86 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/self/root/proc/3/root/sbin/ |
Upload File : |
#!/bin/sh # Copyright © 2013 Filippo Giunchedi <filippo@debian.org> # Copyright © 2013-2016 Luciano Bello <luciano@debian.org> # Copyright © 2022 Samuel Henrique <samueloph@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 files_to_get="https://standards-oui.ieee.org/oui/oui.txt|oui.txt https://standards-oui.ieee.org/oui28/mam.txt|mam.txt https://standards-oui.ieee.org/oui36/oui36.txt|oui36.txt https://standards-oui.ieee.org/iab/iab.txt|iab.txt https://standards-oui.ieee.org/oui/oui.csv|oui.csv https://standards-oui.ieee.org/oui28/mam.csv|mam.csv https://standards-oui.ieee.org/oui36/oui36.csv|oui36.csv https://standards-oui.ieee.org/iab/iab.csv|iab.csv" tmpf=$(mktemp -t "ieee-data_XXXXXX") chmod 0644 "$tmpf" Die () { $QUIET || printf "%s\n" "$1" exit 1 } checkTXT () { TXTOUI='OUI.*\s*Organization\s*.*\s*Organization\s*Address' head -n 6 "$1" | tr -d '\n' | grep -qe "$TXTOUI" return $? } checkCSV () { CSVOUI='Registry,Assignment,Organization Name,Organization Address' head -n 1 "$1" | grep -qe "$CSVOUI" return $? } checkFileHead () { $QUIET || printf "\tChecking header\n" TXTOUI='OUI.*\s*Organization\s*.*\s*Organization\s*Address' checkTXT "$1" || checkCSV "$1" || ( rm "$1" && Die "The downloaded file looks corrupted." ) } checkPerm() { $QUIET || printf "\tChecking permissions on %s\n" "$1" touch -a "$1" || { Die "Touch on $1 exit with $?";} } goAndGet () { $QUIET || printf "Updating %s/%s\n" "$BASEDIR" "$2" checkPerm "$BASEDIR/$2" $QUIET || printf "\tDownloading %s to %s/%s\n" "$1" "$BASEDIR" "$2" $dler "$1" > "$tmpf" || { Die "$dler $1 exit with $?";} checkFileHead "$tmpf" $QUIET || printf "\tTemporary location %s to be moved to %s/%s\n" "$tmpf" "$BASEDIR" "$2" mv -f "$tmpf" "$BASEDIR/$2" $QUIET || printf "\t%s/%s updated.\n" "$BASEDIR" "$2" } while getopts ":fq" opt; do case $opt in f) FORCE=true ;; q) QUIET=true ;; \?) printf "Invalid option: -%s\n" "$OPTARG" >&2 ;; esac done dler="" [ -x "$(command -v curl)" ] && dler="curl -sL" [ -x "$(command -v lwp-request)" ] && dler="lwp-request -m GET" [ -x "$(command -v 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=$(( OLD * 86400 )) CURRENT=$(date +%s) AGE=$(( CURRENT - LASTUPDATE )) if [ $FORCE = false ] && [ $AGE -le $OLD_SECONDS ]; then Die "The files are kinda new yet (less than $OLD days old)" fi for url_and_filename in $(printf "%s\n" "$files_to_get") do url=$(echo "$url_and_filename" | cut -d "|" -f1) file_name=$(echo "$url_and_filename" | cut -d "|" -f2) goAndGet "$url" "$file_name" done rm "$BASEDIR/.lastupdate" printf "%s\n" "$CURRENT" > "$BASEDIR/.lastupdate" if [ -x "$(command -v run-parts)" ] && [ -d update.d ] && [ "$RUN_PARSERS" -ne 0 ]; then $QUIET || printf "\tRunning parsers from %s/update.d\n" "$BASEDIR" run-parts -a "$BASEDIR" -a oui.txt update.d/ run-parts -a "$BASEDIR" -a iab.txt update.d/ run-parts -a "$BASEDIR" -a oui.cvs update.d/ run-parts -a "$BASEDIR" -a iab.cvs update.d/ fi