mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 09:42:38 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -20,13 +20,18 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${OWSEC}" == "" ]]
|
||||
if [[ -z "${OWSEC}" || -z "${OWSEC_USERNAME}" || -z "${OWSEC_PASSWORD}" ]]
|
||||
then
|
||||
echo "You must set the variable OWSEC in order to use this script. Something like"
|
||||
echo "OWSEC=security.isp.com:16001"
|
||||
exit 1
|
||||
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"
|
||||
@@ -37,17 +42,6 @@ result_file=result.json
|
||||
browser_list=(firefox sensible-browser xdg-open w3m links links2 lynx youtube-dl)
|
||||
browser=""
|
||||
|
||||
if [ -z ${OWSEC_USERNAME+x} ]; then
|
||||
username="script.runner@arilia.com"
|
||||
else
|
||||
username=${OWSEC_USERNAME}
|
||||
fi
|
||||
if [ -z ${OWSEC_PASSWORD+x} ]; then
|
||||
password="Snoopy99!!!"
|
||||
else
|
||||
password=${OWSEC_PASSWORD}
|
||||
fi
|
||||
|
||||
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')
|
||||
@@ -552,6 +546,27 @@ rrmprovider() {
|
||||
jq < ${result_file}
|
||||
}
|
||||
|
||||
notifications() {
|
||||
if [[ -z "$1" ]]
|
||||
then
|
||||
timeout=30
|
||||
else
|
||||
timeout=$1
|
||||
fi
|
||||
socket="wss://${OWPROV}/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
|
||||
}
|
||||
|
||||
|
||||
shopt -s nocasematch
|
||||
case "$1" in
|
||||
"login") login; echo "You are logged in..." ; logout ;;
|
||||
@@ -602,6 +617,7 @@ case "$1" in
|
||||
"getvenuedevices") login; getvenuedevices $2; logout;;
|
||||
"listrrmalgos") login; listrrmalgos; logout;;
|
||||
"rrmprovider") login; rrmprovider; logout;;
|
||||
"notifications") login; notifications "$2"; logout;;
|
||||
*) help ;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user