From 8fc9cac2988a296892a8d7f0b3a082a711e45e33 Mon Sep 17 00:00:00 2001 From: dutta-rohan <94938704+dutta-rohan@users.noreply.github.com> Date: Thu, 18 Aug 2022 22:07:54 -0700 Subject: [PATCH] Digicert AP Redirect Script added (#687) Added digicert ap redirect script from scripts directory (since it is private) --- tools/digicert-change-ap-redirector.sh | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tools/digicert-change-ap-redirector.sh diff --git a/tools/digicert-change-ap-redirector.sh b/tools/digicert-change-ap-redirector.sh new file mode 100644 index 000000000..5d10994f3 --- /dev/null +++ b/tools/digicert-change-ap-redirector.sh @@ -0,0 +1,28 @@ +# normalizes a MAC address by removing all non alphanumeric and uppercasing all characters +function normalize_mac() { + local mac=$1 + echo "$mac" | tr -d ":" | tr -d "-" | tr "[:lower:]" "[:upper:]" +} + + +set -e + +# Print usage +if [ $# -lt 1 ]; then + echo "Not enough arguments provided!" + echo "This script gets the redirector URL for an AP identified by the provided MAC address." + echo "Usage: $0 " + echo "mac-address - the primary MAC address of your AP device" + exit 1 +fi + +mac="$(normalize_mac "$1")" + +device_details=$(curl \ + --silent \ + --request GET "${DIGICERT_BASE_URL}v2/device?limit=1&device_identifier=${mac}" \ + --header "x-api-key: $DIGICERT_API_KEY" | jq --raw-output .records[0]) + +current_fields=$(echo "$device_details" | jq --raw-output .fields) + +echo "$current_fields" | jq --raw-output '.[] | select( .name == "Redirector" ) | .value' \ No newline at end of file