Explorar o código

Described dependencies, and made a check for it have been installed on the system.

Dennis Juhler Aagaard hai 1 ano
pai
achega
a9e37c0b01
Modificáronse 1 ficheiros con 65 adicións e 2 borrados
  1. 65 2
      RetreiveUnifiAPMAC.sh

+ 65 - 2
RetreiveUnifiAPMAC.sh

@@ -1,4 +1,14 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+
+# This script depends on the following applications:
+
+#         bash
+#         sshpass
+#         jq
+#         curl
+
+
 
 # UniFi Controller credentials
 CONTROLLER_URL="https://your-controller-url:8443"   # Replace with your Unifi Controller Domain name or IP:PORT
@@ -8,6 +18,59 @@ SITE_NAME="default"                                 # Replace with your site nam
 SSH_USERNAME="your-username"                        # Replace with your SSH username
 SSH_PASSWORD="your-password"                        # Replace with your SSH password
 
+
+
+
+
+
+
+#########################################################################################################
+
+######  Do not edit below this, unless you know what you are doing. :-) #################################
+
+#####   Script made by Dennis Juhler Aagaard                            #################################
+
+#####   License is BSD 0-Clause                                         #################################
+
+# Copyright (C) [year] by [copyright holder] <[email]>                  #################################
+
+# Permission to use, copy, modify, and/or distribute this software for  #################################
+# any purpose with or without fee is hereby granted.                    #################################
+
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL         #################################    
+# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED         #################################
+# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL          #################################
+# THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR            #################################
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS   #################################
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE #################################
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH        #################################
+# THE USE OR PERFORMANCE OF THIS SOFTWARE                               #################################
+
+#########################################################################################################
+if command -v sshpass &> /dev/null; then
+    echo "sshpass is installed"
+    else
+    echo "sshpass is not installed."
+    echo "install it by running your favourite pkg manager."
+    exit 1
+fi
+if command -v jq &> /dev/null; then
+    echo "jq is installed"
+    else
+    echo "jq is not installed."
+    echo "install it by running your favourite pkg manager."
+    exit 1
+fi
+if command -v curl &> /dev/null; then
+    echo "curl is installed"
+    else
+    echo "curl is not installed."
+    echo "install it by running your favourite pkg manager."
+    exit 1
+fi
+echo ""
+
+
 # Function to retrieve site ID
 get_site_id() {
     SITES_RESPONSE=$(curl --silent --insecure --cookie /tmp/unifi_cookie \
@@ -82,7 +145,7 @@ AP_LIST=$(echo ${DEVICE_LIST} | jq -r '.data[] | select(.type=="uap") | "\(.name
 
 # Output header
 echo "Access Point Name, 2.4GHz MAC Address"
-
+echo ""
 # Check if AP_LIST is empty and print a message if it is
 if [ -z "$AP_LIST" ]; then
     echo "No access points found or unable to retrieve access points. Please check your UniFi Controller settings."