From 838aa1df81a8689924ab58223162f485cf725049 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Mon, 11 Apr 2022 16:35:56 +0200 Subject: [PATCH] Auto-download on demand and give warning if file is old --- bin/mac.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/mac.sh b/bin/mac.sh index 7cd65e2..c084f35 100755 --- a/bin/mac.sh +++ b/bin/mac.sh @@ -14,8 +14,20 @@ ouilocation="${HOME}/.dot/oui.txt" ################# if [ ! -f "${ouilocation}" ] ; then - echo 'OUI location can not be found. Have you updated the config?' 1>&2 - exit 1 + echo "OUI location can not be found at ${ouilocation}. Have you updated the config?" 1>&2 + read -p "Do you want to download it now [y/N]? " -n 1 -r + echo # (optional) move to a new line + if [[ $REPLY =~ ^[Yy]$ ]] + then + wget https://standards-oui.ieee.org/oui/oui.txt -O "${ouilocation}" + else + echo "Aborted" + exit 1 + fi +fi + +if [[ $(find "${ouilocation}" -mtime +30 -print) ]]; then + echo "File ${ouilocation} is older than 30 days" fi if [ -z "${1}" ] ; then