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