mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-11-01 19:28:01 +00:00
1253 lines
42 KiB
Bash
Executable File
1253 lines
42 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# License type: BSD 3-Clause License
|
|
# License copy: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
|
#
|
|
# Created by Stephane Bourque on 2021-03-04.
|
|
# Arilia Wireless Inc.
|
|
#
|
|
|
|
if [[ "$(which jq)" == "" ]]
|
|
then
|
|
echo "You need the package jq installed to use this script."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$(which curl)" == "" ]]
|
|
then
|
|
echo "You need the package curl installed to use this script."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "${OWSEC}" || -z "${OWSEC_USERNAME}" || -z "${OWSEC_PASSWORD}" ]]
|
|
then
|
|
echo "You must set the variables OWSEC, OWSEC_USERNAME, and OWSEC_PASSWORD in order to use this script. Something like"
|
|
echo "export OWSEC=security.isp.com:16001"
|
|
echo "export OWSEC_USERNAME=theusername@domain.com"
|
|
echo "export OWSEC_PASSWORD=mytoughpassword"
|
|
exit 1
|
|
fi
|
|
|
|
username=${OWSEC_USERNAME}
|
|
password=${OWSEC_PASSWORD}
|
|
|
|
if [[ "${FLAGS}" == "" ]]
|
|
then
|
|
FLAGS="-s"
|
|
fi
|
|
|
|
token=""
|
|
result_file=result.json
|
|
browser_list=(firefox sensible-browser xdg-open w3m links links2 lynx youtube-dl)
|
|
browser=""
|
|
|
|
|
|
login() {
|
|
payload="{ \"userId\" : \"$username\" , \"password\" : \"$password\" }"
|
|
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${OWSEC}/api/v1/oauth2" | jq -r '.access_token')
|
|
if [[ "${token}" == "" ]]
|
|
then
|
|
echo "Could not login. Please verify the host and username/password."
|
|
exit 13
|
|
fi
|
|
echo "${token}" > token.json
|
|
setgateway
|
|
}
|
|
|
|
findbrowser() {
|
|
if [[ "${browser}" != "" ]]
|
|
then
|
|
echo
|
|
elif [[ "$(uname)" == "Darwin" ]]
|
|
then
|
|
browser=open
|
|
else
|
|
browser_list=(firefox sensible-browser xdg-open w3m links links2 lynx youtube-dl)
|
|
for br_name in "${browser_list[@]}"
|
|
do
|
|
if [[ $(which "${br_name}") != "" ]]
|
|
then
|
|
browser=${br_name}
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
setgateway() {
|
|
if [ -z ${OWGW_OVERRIDE+x} ]; then
|
|
curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemEndpoints" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
rawurl="$(cat < ${result_file} | jq -r '.endpoints[] | select( .type == "owgw" ) | .uri')"
|
|
if [[ ! -z "${rawurl}" ]]; then
|
|
proto="$(echo "$rawurl" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
|
url="$(echo "${rawurl/$proto/}")"
|
|
user="$(echo $url | grep @ | cut -d@ -f1)"
|
|
export OWGW=${url}
|
|
echo "Using ${OWGW}..."
|
|
else
|
|
echo "OWGW endpoint is not found:"
|
|
jq < ${result_file}
|
|
exit 1
|
|
fi
|
|
else
|
|
export OWGW=${OWGW_OVERRIDE}
|
|
fi
|
|
}
|
|
|
|
logout() {
|
|
curl ${FLAGS} -X DELETE "https://${OWSEC}/api/v1/oauth2/${token}" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
rm -rf token.json
|
|
}
|
|
|
|
getdevice() {
|
|
curl ${FLAGS} -X GET --url "https://${OWGW}/api/v1/device/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getcommand() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/command/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletecommand() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/command/$1" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
listcommands() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/commands?serialNumber=$1&limit=300" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
newestcommands() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/commands?serialNumber=$1&newest=true&limit=50" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletecommands() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/commands?serialNumber=$1" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
getcapabilities() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/capabilities" \
|
|
-H "accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletecapabilities() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1/capabilities" \
|
|
-H "accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
listdevices() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletesimdevices() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/devices?simulatedOnly=true&macPattern=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletebulkdevices() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/devices?macPattern=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
listdevicesk() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "X-API-KEY: $1" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
ldevs() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?offset=$1&limit=$2" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletedevice() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deleteoui() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1?oui=true" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
|
|
createdevice() {
|
|
payload="{ \"serialNumber\": \"$1\", \"UUID\": 1234456, \"configuration\" : $(cat "$2") , \"deviceType\": \"AP\",\"location\": \"\", \"macAddress\": \"$3\", \"manufacturer\": \"Linksys EA8300 (Dallas)\", \"owner\": \"\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
addnote() {
|
|
payload="{ \"serialNumber\": \"$1\", \"notes\" : [ {\"note\" : \"$2\"} ] }"
|
|
curl ${FLAGS} -X PUT "https://${OWGW}/api/v1/device/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
reboot() {
|
|
payload="{ \"serialNumber\" : \"$1\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/reboot" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
setloglevel() {
|
|
payload="{ \"command\" : \"setloglevel\" , \"subsystems\" : [ { \"tag\" : \"$1\" , \"value\" : \"$2\" } ] }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getloglevels() {
|
|
payload="{ \"command\" : \"getloglevels\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getloglevelnames() {
|
|
payload="{ \"command\" : \"getloglevelnames\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getsubsystemnames() {
|
|
payload="{ \"command\" : \"getsubsystemnames\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
systeminfo() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/system?command=info" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
systemresources() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/system?command=resources" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
reloadsubsystem() {
|
|
payload="{ \"command\" : \"reload\", \"subsystems\" : [ \"$1\" ] }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload"
|
|
}
|
|
|
|
getdevicestatus() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/status" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getdevicecomplete() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1?completeInfo=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
upgrade() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"uri\" : \"$2\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/upgrade" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
leds() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"duration\" : $3, \"pattern\" : \"$2\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/leds" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
factory() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"keepRedirector\" : $2 }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/factory" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
configure() {
|
|
payload="{ \"serialNumber\" : \"$1\", \"UUID\" : 123456 , \"configuration\" : $(cat "$2") }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/configure" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
request() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"message\" : \"$2\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/request" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
wifiscan() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"verbose\" : $2 }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/wifiscan" \
|
|
--max-time 120 \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
activescan() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"verbose\" : $2, \"activeScan\" : true}"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/wifiscan" \
|
|
--max-time 120 \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
trace() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"duration\" : $2, \"network\" : \"$3\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/trace" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getstats() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getlogs() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/logs" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletelogs() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1/logs" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
gethealthchecks() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getdefaultconfig() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/default_configuration/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
createdefaultconfig() {
|
|
payload="{ \"name\": \"$1\", \"modelIds\" : \"[$2]\", \"configuration\" : $(cat "$3")}"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/default_configuration/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletedefaultconfig() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/default_configuration/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
jq < ${result_file}
|
|
}
|
|
|
|
listdefaultconfigs() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/default_configurations" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
addblacklistdevice() {
|
|
payload="{ \"serialNumber\": \"$1\" , \"reason\" : \"$2\" }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/blacklist/1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deleteblacklistdevice() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/blacklist/$1" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
getblacklist() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/blacklist" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
modblacklistdevice() {
|
|
payload="{ \"serialNumber\": \"$1\" , \"reason\" : \"$2\" }"
|
|
curl ${FLAGS} -X PUT "https://${OWGW}/api/v1/blacklist/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
eventqueue() {
|
|
payload="{ \"serialNumber\" : \"$1\" , \"types\" : [ \"dhcp\", \"wifi\" ] }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/eventqueue" \
|
|
--max-time 120 \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
selectdevices() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?select=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deviceserialnumbers() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?serialOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deviceswithstatus() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?deviceWithStatus=true&limit=500" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
devicecount() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?countOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getfile() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/file/$2?serialNumber=$1" \
|
|
-H "accept: */*" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-O -J
|
|
}
|
|
|
|
gethealthrange() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?health=true&lowLimit=$1&highLimit=$2" \
|
|
-H "accept: */*" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
rtty() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/rtty" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
|
|
if [[ "$2" != "noconnect" ]]
|
|
then
|
|
cid=$(cat ${result_file} | jq -r '.connectionId')
|
|
vport=$(cat ${result_file} | jq -r '.viewport')
|
|
server=$(cat ${result_file} | jq -r '.server')
|
|
url=https://${server}:${vport}/connect/${cid}
|
|
findbrowser
|
|
if [[ "${browser}" != "" ]]
|
|
then
|
|
${browser} ${url}
|
|
fi
|
|
fi
|
|
}
|
|
|
|
laststats() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?lastOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
lasthealthcheck() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks?lastOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
neweststats() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?newest=true&limit=50" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
newestlogs() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/logs?newest=true&limit=50" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
newesthealthchecks() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks?newest=true&limit=50" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
ouilookup() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/ouis?macList=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
dashboard() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/deviceDashboard" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
validateconfig() {
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/1?validateOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-H "accept: application/json" \
|
|
-d @"$1" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
|
|
wstest() {
|
|
echo "Token:${token}"
|
|
wscat \
|
|
-c wss://"${OWGW}"/api/v1/ws
|
|
}
|
|
|
|
telemetry() {
|
|
payload="{ \"serialNumber\" : \"$1\", \"interval\" : 2 , \"types\" : [ \"wifi-frames\", \"dhcp-snooping\", \"state\" ] }"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/telemetry" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
socket=$(jq -r '.uri' < result.json)
|
|
if [[ "$(which wscat)" == "" ]]
|
|
then
|
|
echo "wscat command not found. Cannot start a websocket session."
|
|
else
|
|
wscat \
|
|
-c "${socket}"
|
|
fi
|
|
}
|
|
|
|
notifications() {
|
|
if [[ -z "$1" ]]
|
|
then
|
|
timeout=30
|
|
else
|
|
timeout=$1
|
|
fi
|
|
socket="wss://${OWGW}/api/v1/ws"
|
|
echo "${socket}"
|
|
if [[ "$(which wscat)" == "" ]]
|
|
then
|
|
echo "wscat command not found. Cannot start a websocket session."
|
|
else
|
|
wscat \
|
|
--connect "${socket}" "token:${token}" \
|
|
--wait $timeout \
|
|
--execute "token:${token}"
|
|
fi
|
|
}
|
|
|
|
telemetry_to_kafka() {
|
|
payload="$(printf '{ "serialNumber": "%s", "interval": 2, "kafka": true, "lifetime": %d, "types": [ "dhcp-snooping", "state", "wifi-frames" ] }' "$1" "$2")"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/telemetry" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
runscript() {
|
|
scriptcontent=$(base64 -i "$3")
|
|
payload="$(printf '{ "serialNumber": "%s", "type": "%s" , "timeout": 30, "script" : "%s" , "deferred" : false, "when" : 0 }' "$1" "$2" "$scriptcontent" )"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/script" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
runscriptname() {
|
|
payload="$(printf '{ "serialNumber": "%s", "type": "%s" , "timeout": 30, "scriptId" : "%s" , "when" : 0 }' "$1" "$2" "$3" )"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/script" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deviceping() {
|
|
payload="$(printf '{ "serialNumber": "%s" }' "$1" )"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/ping" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
caplist() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/capabilities" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
iptocountry() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/iptocountry?iplist=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
setradiusconfig() {
|
|
curl ${FLAGS} -X PUT "https://${OWGW}/api/v1/radiusProxyConfig" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-d "@${1}" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getradiusconfig() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/radiusProxyConfig" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deleteradiusconfig() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/radiusProxyConfig" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
connectionstatistics() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?connectionStatistics=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
testtoken() {
|
|
login
|
|
systeminfo
|
|
logout
|
|
systeminfo
|
|
}
|
|
|
|
# retreive the stats for a snigle device for the last 7 days
|
|
stats7() {
|
|
now=$(date +%s)
|
|
len=$((7 * 24 * 60 * 60))
|
|
start=$((now - len))
|
|
offset=0
|
|
records=100
|
|
while [ ${records} == 100 ]
|
|
do
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?startDate=${start}&endDate=${now}&offset=${offset}&limit=100" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
# jq < ${result_file}
|
|
records=$(jq '.data | length' ${result_file})
|
|
offset=$((offset + ${records}))
|
|
echo "Downloaded ${records} records. New offset is ${offset}"
|
|
if [[ ${records} != 100 ]]
|
|
then
|
|
break
|
|
fi
|
|
done
|
|
|
|
}
|
|
|
|
stats7count() {
|
|
now=$(date +%s)
|
|
len=$((7 * 24 * 60 * 60))
|
|
start=$((now - len))
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?startDate=${start}&endDate=${now}&countOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
listscripts() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/scripts" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getscript() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/script/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
regulatory() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/regulatory?countries=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
regulatory_reload() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/regulatory?reload=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
radiussessions() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/radiusSessions/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
radiussearch() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/radiusSessions/0?userName=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
radiussearchmac() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/radiusSessions/0?mac=$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
radiusaps() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/radiusSessions/0?serialNumberOnly=true" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
radiuscoadm() {
|
|
payload="$(printf '{ "accountingSessionId": "%s", "accountingMultiSessionId": "%s" , "callingStationId": "%s" }' "$2" "$3" "$4" )"
|
|
curl ${FLAGS} -X PUT "https://${OWGW}/api/v1/radiusSessions/$1?operation=coadm" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
listdefaultfirmwares() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/default_firmwares" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
getdefaultfirmware() {
|
|
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/default_firmware/$1" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
transferdevice() {
|
|
payload="$(printf '{ "serialNumber": "%s", "server": "%s" , "port": %s}' "$1" "$2" "$3")"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/transfer" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
certupdate() {
|
|
payload="$(printf '{ "serialNumber": "%s", "encodedCertificate": "%s"}' "$1" "$2")"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/certupdate" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
rrm_kick() {
|
|
payload="$(printf '{ "actions" : [{ "action": "kick", "addr": "%s", "reason": %s, "ban_time": %s}] }' "$2" "$3" "$4")"
|
|
echo "$payload"
|
|
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/rrm" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-d "$payload" > ${result_file}
|
|
jq < ${result_file}
|
|
}
|
|
|
|
deletesimulateddevices() {
|
|
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/devices?simulatedDevices=true" \
|
|
-H "Accept: application/json" \
|
|
-H "Authorization: Bearer ${token}"
|
|
}
|
|
|
|
check_response() {
|
|
|
|
if [ -s "$1" ]; then
|
|
ERROR_CODE="$(jq -r '.ErrorCode' < $1)"
|
|
|
|
if [[ -n "$ERROR_CODE" && "$ERROR_CODE" != 'null' ]]; then
|
|
echo "Error: got HTTP error code $ERROR_CODE, exiting"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Error: result file not found or empty"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
test_service() {
|
|
echo
|
|
echo "----------------------"
|
|
echo "Get system information"
|
|
echo "----------------------"
|
|
systeminfo
|
|
check_response $result_file
|
|
|
|
echo
|
|
echo "-----------------"
|
|
echo "Get device status"
|
|
echo "-----------------"
|
|
SECONDS=0
|
|
TIMEOUT_SECONDS=900
|
|
|
|
while (( $SECONDS < $TIMEOUT_SECONDS )); do
|
|
getdevicestatus $1
|
|
check_response $result_file
|
|
DEVICE_STATUS="$(jq -r '.connected' < $result_file)"
|
|
|
|
if [ "$DEVICE_STATUS" != true ]; then
|
|
echo "Waiting for AP to connect, $SECONDS elapsed"
|
|
sleep 10
|
|
else
|
|
jq < $result_file
|
|
break
|
|
fi
|
|
|
|
done
|
|
|
|
if (( $SECONDS >= $TIMEOUT_SECONDS )); then
|
|
echo "Error: timed out waiting for AP to connect"
|
|
exit 1
|
|
fi
|
|
|
|
echo
|
|
echo "--------------------"
|
|
echo "Create network trace"
|
|
echo "--------------------"
|
|
trace "$1" 5 up
|
|
check_response $result_file
|
|
TRACE_STATUS="$(jq -r '.status' < $result_file)"
|
|
|
|
if [ "$TRACE_STATUS" != 'completed' ]; then
|
|
echo "Error: failed to create network trace"
|
|
exit 1
|
|
fi
|
|
|
|
TRACE_ID="$(jq -r '.UUID' < $result_file)"
|
|
|
|
echo
|
|
echo "-----------------"
|
|
echo "Get network trace"
|
|
echo "-----------------"
|
|
getfile $1 $TRACE_ID
|
|
|
|
TRACE_RESPONSE="$(jq < "$TRACE_ID".pcap 2>/dev/null)"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
check_response $TRACE_ID.pcap
|
|
else
|
|
echo "Successfully downloaded trace to file $TRACE_ID.pcap"
|
|
fi
|
|
|
|
echo
|
|
echo "-----------------------------"
|
|
echo "Create and start RTTY session"
|
|
echo "-----------------------------"
|
|
rtty "$1"
|
|
check_response $result_file
|
|
RTTY_STATUS="$(curl ${FLAGS} -L -v $url 2>&1 | awk '/200/')"
|
|
|
|
if [[ -z "$RTTY_STATUS" ]]; then
|
|
echo "Error: failed to start RTTY session, HTTP status code $RTTY_STATUS"
|
|
exit 1
|
|
else
|
|
echo "RTTY session at $url was successfully started"
|
|
fi
|
|
}
|
|
|
|
help() {
|
|
echo
|
|
echo "getdevice <serial> Get the device JSON document."
|
|
echo "deletedevice <serial> Delete the device."
|
|
echo "createdevice <serial> <cfg> <MAC> Create a device using the default configuration."
|
|
echo "validateconfig <config file> Validate a configuration file."
|
|
echo " cfg: JSON config file name"
|
|
echo " <MAC>: string MAC Address"
|
|
echo "getdevicestatus <serial> Get the device status JSON document."
|
|
echo "getstats <serial> Get statistics for the device."
|
|
echo "gethealthchecks <serial> Get healthchecks for a device."
|
|
echo "newesthealthchecks <serial> Get newest healthchecks for a device."
|
|
echo "lasthealthcheck <serial> Get the last healthcheck"
|
|
echo "addnote <serial> <note> Add a notes to the notes section"
|
|
echo
|
|
echo "getcapababilities <serial> Get the device capabilities JSON document."
|
|
echo "deletecapababilities <serial> Delete the device capabilities JSON."
|
|
echo
|
|
echo "reboot <serial> Reboot the device."
|
|
echo "upgrade <serial> <URI> Do firmware upgrade for a device."
|
|
echo "leds <serial> <pattern> <d> Activate LEDs a device."
|
|
echo " pattern: on/off/blink"
|
|
echo " d: number in seconds"
|
|
echo "configure <serial> <cfg> Change configuration for a device."
|
|
echo " cfg must be valid JSON config."
|
|
echo "factory <serial> <true/false> Do factory reset for device. true=keep redirector, false=reset redirector"
|
|
echo "request <serial> <message> Force a message from the device."
|
|
echo " message=state/healthcheck"
|
|
echo "wifiscan <serial> <verbose> Do wifiscan for a device."
|
|
echo " verbose=true/false"
|
|
echo "active <serial> <verbose> Do an active wifiscan for a device."
|
|
echo " verbose=true/false"
|
|
echo "trace <serial> <d> <n> Launch a remote trace for a device."
|
|
echo " d=number of seconds"
|
|
echo " n=lan/wan"
|
|
echo
|
|
echo "getcommand <command-uuid> Get the command JSON document."
|
|
echo "deletecommand <command-uuid> Delete the command."
|
|
echo "newestcommands <serial> Get the newest commands for a device."
|
|
echo "listdevices List devices"
|
|
echo "listcommands <serial> List commands for a specific device"
|
|
echo "deletecommands <serial> Delete commands for a device."
|
|
echo
|
|
echo "getlogs <serial> Get logs for the device."
|
|
echo "newestlogs <serial> Get the latest logs for the device."
|
|
echo "deletelogs <serial> Delete logs for the device."
|
|
echo "eventqueue <serial> Request event queue for the device."
|
|
echo
|
|
echo "listdefaultconfigs List a default configurations"
|
|
echo "createdefaultconfig <name> <ids> <cfg> Create a default configuration"
|
|
echo " name=unique name, no spaces"
|
|
echo " ids=coma separated list of models"
|
|
echo " cfg=config file name"
|
|
echo "deletedefaultconfig <name> Delete a default configuration"
|
|
echo
|
|
echo "addblacklistdevice <serial> <r> Add a device to the black list"
|
|
echo " <r> Reason for blacklisting"
|
|
echo "getblacklist List all blacklisted devices"
|
|
echo "deleteblacklistdevice <serial> Add a device to the black list"
|
|
echo
|
|
echo "devicecount Get the number of devices in the DB"
|
|
echo "deviceserialnumbers Get only the serial numbers"
|
|
echo "selectdevices <serial list> get a list of serial numbers (must be comma separated)"
|
|
echo "deviceswithstatus Get devices with their status"
|
|
echo
|
|
echo "setloglevel <sys> <level> Set the logging system level for individual subsystems."
|
|
echo " sys:ufileuploader/websocket/storage/restapi/commandmanager/auth/deviceregistry/all"
|
|
echo " level:none/fatal/critical/error/warning/notice/information/debug/trace"
|
|
echo "getloglevels Get the log levels of all the subsystems"
|
|
echo "getloglevelnames Get the list of log level names possible"
|
|
echo "getsubsystemnames Get the subsystems that can be used when setting log levels."
|
|
echo "getfile <serial> <uuid> <name> Get the file associated with trace command <uuid> for device <serial>"
|
|
echo " The file will be saved with the name <name>"
|
|
echo
|
|
echo "rtty <serial> <noconnect> Get the details for an rtty session."
|
|
echo
|
|
echo "laststats <serial> Get the last statistics for a device"
|
|
echo "neweststats <serial> Get the newest statistics for a device"
|
|
echo
|
|
echo "ouilookup <serial> Lookup an OUI"
|
|
echo
|
|
echo "dashboard Get the dashboard document"
|
|
echo "systeminfo Get information on the system running the service."
|
|
echo
|
|
echo "wstest Testing the WebSocket interface."
|
|
echo
|
|
echo "test_service <serial> Run a set of CLI commands for testing purposes"
|
|
echo "runscript <serial> <type> <script> Run a script. type must be uci, ucode, shell."
|
|
echo
|
|
echo
|
|
echo "To pass additional flags to the CURL command, create an environment variable called FLAGS and git ve the values you"
|
|
echo "want. For example, for force all call to use IPv6, set FLAGS=\"-6\", for verbose mode and IPv6, set FLAGS=\"-6 -v\""
|
|
echo
|
|
echo
|
|
}
|
|
|
|
shopt -s nocasematch
|
|
case "$1" in
|
|
"getdevice") login; getdevice "$2"; logout ;;
|
|
"help") login; help ; logout ;;
|
|
"getcommand") login; getcommand "$2" ; logout ;;
|
|
"deletecommand") login; deletecommand "$2" ; logout ;;
|
|
"getcapabilities") login; getcapabilities "$2" ; logout ;;
|
|
"deletecapabilities") login; deletecapabilities "$2" ; logout ;;
|
|
"listdevices") login; listdevices ; logout ;;
|
|
"listdevicesk") login; listdevicesk "$2" ; logout ;;
|
|
"deletedevice") login; deletedevice "$2" ; logout ;;
|
|
"deleteoui") login; deleteoui "$2" ; logout ;;
|
|
"createdevice") login; createdevice "$2" "$3" "$4" ; logout ;;
|
|
"reboot") login; reboot "$2" ; logout ;;
|
|
"getdevicestatus") login; getdevicestatus "$2" ; logout ;;
|
|
"upgrade") login; upgrade "$2" "$3" ; logout ;;
|
|
"factory") login; factory "$2" "$3" ; logout ;;
|
|
"leds") login; leds "$2" "$3" "$4" ; logout ;;
|
|
"listcommands") login; listcommands "$2" ; logout ;;
|
|
"deletecommands") login; deletecommands "$2" ; logout ;;
|
|
"configure") login; configure "$2" "$3" ; logout ;;
|
|
"request") login; request "$2" "$3" ; logout ;;
|
|
"wifiscan") login; wifiscan "$2" "$3" ; logout ;;
|
|
"activescan") login; activescan "$2" "$3" ; logout ;;
|
|
"trace") login; trace "$2" "$3" "$4" ; logout ;;
|
|
"getstats") login; getstats "$2" ; logout ;;
|
|
"getlogs") login; getlogs "$2" ; logout ;;
|
|
"deletelogs") login; deletelogs "$2" ; logout ;;
|
|
"gethealthchecks") login; gethealthchecks "$2" ; logout ;;
|
|
"createdefaultconfig") login; createdefaultconfig "$2" "$3" "$4" ; logout ;;
|
|
"getdefaultconfig") login; getdefaultconfig "$2" ; logout ;;
|
|
"deletedefaultconfig") login; deletedefaultconfig "$2" ; logout ;;
|
|
"listdefaultconfigs") login; listdefaultconfigs "$2" ; logout ;;
|
|
"addblacklistdevice") login; addblacklistdevice "$2" "$3" ; logout ;;
|
|
"deleteblacklistdevice") login; deleteblacklistdevice "$2" ; logout ;;
|
|
"getblacklist") login; getblacklist ; logout ;;
|
|
"modblacklistdevice") login; modblacklistdevice "$2" "$3" ; logout;;
|
|
"eventqueue") login; eventqueue "$2" ; logout ;;
|
|
"selectdevices") login; selectdevices "$2" ; logout ;;
|
|
"deviceserialnumbers") login; deviceserialnumbers ; logout ;;
|
|
"devicecount") login; devicecount ; logout ;;
|
|
"deviceswithstatus") login; deviceswithstatus "$2" ; logout ;;
|
|
"getdevicecomplete") login; getdevicecomplete "$2" ; logout ;;
|
|
"getfile") login; getfile "$2" "$3" ; logout ;;
|
|
"rtty") login; rtty "$2" "$3" ; logout ;;
|
|
"laststats") login; laststats "$2"; logout;;
|
|
"newestcommands") login; newestcommands "$2"; logout;;
|
|
"neweststats") login; neweststats "$2"; logout;;
|
|
"newestlogs") login; newestlogs "$2"; logout;;
|
|
"newesthealthchecks") login; newesthealthchecks "$2"; logout;;
|
|
"lasthealthcheck") login; lasthealthcheck "$2"; logout;;
|
|
"login") login ;;
|
|
"findbrowser") findbrowser; echo "Browser: ${browser}" ;;
|
|
"setloglevel") login; setloglevel "$2" "$3" ; logout ;;
|
|
"getloglevels") login; getloglevels; logout ;;
|
|
"getloglevelnames") login; getloglevelnames; logout ;;
|
|
"getsubsystemnames") login; getsubsystemnames; logout ;;
|
|
"reloadsubsystem") login; reloadsubsystem "$2"; logout ;;
|
|
"systeminfo") login; systeminfo ; logout;;
|
|
"systemresources") login; systemresources ; logout;;
|
|
"ouilookup") login; ouilookup "$2"; logout;;
|
|
"telemetry") login; telemetry "$2"; logout;;
|
|
"telemetry_to_kafka") login; telemetry_to_kafka "$2" "$3"; logout;;
|
|
"dashboard") login; dashboard ; logout;;
|
|
"addnote") login; addnote "$2" "$3"; logout;;
|
|
"ldevs") login; ldevs "$2" "$3"; logout ;;
|
|
"validateconfig") login; validateconfig "$2" ; logout ;;
|
|
"wstest") login; wstest; logout;;
|
|
"caplist") login; caplist; logout;;
|
|
"iptocountry") login; iptocountry "$2"; logout;;
|
|
"test_service") login; test_service "$2"; logout;;
|
|
"runscript") login; runscript "$2" "$3" "$4"; logout;;
|
|
"runscriptname") login; runscriptname "$2" "$3" "$4"; logout;;
|
|
"getradiusconfig") login; getradiusconfig ; logout;;
|
|
"setradiusconfig") login; setradiusconfig "$2"; logout;;
|
|
"deleteradiusconfig") login; deleteradiusconfig ; logout;;
|
|
"deviceping") login; deviceping "$2"; logout;;
|
|
"connectionstatistics") login; connectionstatistics "$2"; logout;;
|
|
"notifications") login; notifications "$2"; logout;;
|
|
"stats7") login; stats7 "$2"; logout;;
|
|
"stats7count") login; stats7count "$2"; logout;;
|
|
"listscripts") login; listscripts; logout;;
|
|
"getscript") login; getscript "$2"; logout;;
|
|
"regulatory") login; regulatory "$2"; logout;;
|
|
"regulatory_reload") login; regulatory_reload; logout;;
|
|
"gethealthrange") login; gethealthrange "$2" "$3"; logout;;
|
|
"radiussessions") login; radiussessions $2; logout;;
|
|
"radiusaps") login; radiusaps ; logout;;
|
|
"radiuscoadm") login; radiuscoadm "$2" "$3" "$4" "$5"; logout;;
|
|
"radiussearch") login; radiussearch "$2"; logout;;
|
|
"radiussearchmac") login; radiussearchmac "$2"; logout;;
|
|
"deletesimdevices") login; deletesimdevices "$2"; logout;;
|
|
"deletebulkdevices") login; deletebulkdevices "$2"; logout;;
|
|
"listdefaultfirmwares") login; listdefaultfirmwares; logout;;
|
|
"getdefaultfirmware") login; getdefaultfirmware "$2"; logout;;
|
|
"transferdevice") login; transferdevice "$2" "$3" "$4"; logout;;
|
|
"certupdate") login; certupdate "$2" "$3"; logout;;
|
|
"rrm_kick") login; rrm_kick "$2" "$3" "$4" "$5"; logout;;
|
|
"deletesimulateddevices") login; deletesimulateddevices ; logout;;
|
|
"testtoken") testtoken;;
|
|
*) help ;;
|
|
esac
|
|
|