Added the script for getting a meraki network list

This commit is contained in:
Marcin Woźniak 2022-09-03 23:28:25 +02:00
parent ec162b3db5
commit 5a295b2a6d
Signed by: y0rune
GPG Key ID: F204C385F57EB348

View File

@ -0,0 +1,44 @@
#!/bin/bash
################################################################################
#
# Marcin Wozniak
# y0rune@aol.com
#
# That script is for easier getting a Meraki network list
#
# shellcheck disable=1091,2048
################################################################################
set -e
function timestamp() {
echo "[+] $(date +'%F %T') [INFO] $*"
}
function err() {
echo "[-] $(date +'%F %T') [ERROR] $*" >&2
}
function command_start() {
timestamp "Command $* has been started."
if ! $*; then
err "Command $* went wrong."
exit
fi
timestamp "Command $* has been ended."
}
function main() {
[ -z "$MERAKI_API_KEY" ] && err "Meraki Key is not set up. Please set it via export MERAKI_API_KEY=<XXXXX>"
[ -z "$MERAKI_ORG_ID" ] && err "Meraki Organization ID is not set up. Please set it via export MERAKI_ORG_ID=<XXXXX>"
timestamp "Getting a list of the network"
curl --silent \
-H 'Content-Type: application/json' \
-H 'X-Cisco-Meraki-API-Key: '"$MERAKI_API_KEY"'' \
https://api.meraki.com/api/v1/organizations/"$MERAKI_ORG_ID"/networks |
jq -M '.[] | .id + " " + .name'
}
main "$@"