From 3931ed37d1584782b0c8d3e40065cee7edd10581 Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Tue, 11 May 2021 16:44:19 +0200 Subject: [PATCH] Clean up the status script output a bit --- scripts/common.sh | 6 +++ scripts/drogue.sh | 2 +- scripts/endpoints.sh | 22 ++++++++ scripts/status.sh | 125 +++++++++++++++++-------------------------- 4 files changed, 78 insertions(+), 77 deletions(-) mode change 100644 => 100755 scripts/endpoints.sh diff --git a/scripts/common.sh b/scripts/common.sh index 9dbb6bc3c..81ab7d6ab 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -152,3 +152,9 @@ function wait_for_ksvc() { exit 1 fi } + +function bold() { + tput bold || : + echo "$@" + tput sgr0 || : +} \ No newline at end of file diff --git a/scripts/drogue.sh b/scripts/drogue.sh index 568a07bb7..6b948a014 100755 --- a/scripts/drogue.sh +++ b/scripts/drogue.sh @@ -102,7 +102,7 @@ esac; # source the endpoint information -source "${SCRIPTDIR}/endpoints.sh" +SILENT=true source "${SCRIPTDIR}/endpoints.sh" # Provide a TLS certificate for the MQTT endpoint diff --git a/scripts/endpoints.sh b/scripts/endpoints.sh old mode 100644 new mode 100755 index 716f6a670..d7b52c75d --- a/scripts/endpoints.sh +++ b/scripts/endpoints.sh @@ -66,3 +66,25 @@ while [ -z "$SSO_URL" ]; do echo "Waiting for Keycloak ingress to get ready! If you're running minikube, run 'minikube tunnel' in another shell and ensure that you have the ingress addon enabled." SSO_URL="$(ingress_url "keycloak")" done + +if [[ -z "$SILENT" ]]; then + + echo + bold "========================================================" + bold " Services" + bold "========================================================" + echo + echo "Console: $CONSOLE_URL" + echo + echo "Backend: $BACKEND_URL" + echo "Device Registry: $MGMT_URL" + echo + echo "Command endpoint: $COMMAND_ENDPOINT_URL" + echo + echo "HTTP Endpoint: $HTTP_ENDPOINT_URL" + echo "MQTT Endpoint: $MQTT_ENDPOINT_HOST:$MQTT_ENDPOINT_PORT" + echo + echo "MQTT Integration: $MQTT_INTEGRATION_HOST:$MQTT_INTEGRATION_PORT" + echo + +fi \ No newline at end of file diff --git a/scripts/status.sh b/scripts/status.sh index 92021d7f7..b2ab0a8f0 100755 --- a/scripts/status.sh +++ b/scripts/status.sh @@ -8,76 +8,47 @@ source "$SCRIPTDIR/common.sh" : "${CONSOLE:=true}" : "${DIGITAL_TWIN:=false}" -source "${SCRIPTDIR}/endpoints.sh" +SILENT=true source "${SCRIPTDIR}/endpoints.sh" # Dump out the dashboard URL and sample commands for http and mqtt echo -echo "==========================================================================================" -echo " Base:" -echo "==========================================================================================" +bold "==========================================================================================" +bold " Base" +bold "==========================================================================================" echo - -echo "SSO:" -echo " url: $SSO_URL" -echo " user: admin" -echo " password: admin123456" +bold "Single sign-on:" +echo " URL: $SSO_URL" +echo " User: admin" +echo " Password: admin123456" echo -echo "Admin user (via SSO):" -echo " user: admin" -echo " password: admin123456" +echo "$(bold -n Console:) $CONSOLE_URL" echo - -if [ $CONSOLE = "true" ] ; then - echo "Console:" - echo " url: $CONSOLE_URL" - echo " user: " - echo -fi - -echo "------------------------------------------------------------------------------------------" -echo "Examples" -echo "------------------------------------------------------------------------------------------" +bold "------------------------------------------------------------------------------------------" +bold "Examples" +bold "------------------------------------------------------------------------------------------" echo -echo "View the dashboard:" -echo "---------------------" +bold "View the example dashboard:" +bold "----------------------------" echo -echo "* Login to Grafana:" -echo " url: $DASHBOARD_URL" -echo " user: " -echo "* Try this link: $DASHBOARD_URL/d/YYGTNzdMk/" -echo "* Or search for the 'Knative test' dashboard" -echo "* Additional admin user:" -echo " username: admin" -echo " password: admin123456" +echo "* Login to Grafana (using SSO): $DASHBOARD_URL" +echo "* Search for the 'Examples' dashboard" echo -echo "Login in with 'drg':" -echo "---------------------" +bold "Login in with 'drg':" +bold "---------------------" echo echo " drg login $BACKEND_URL" echo -echo "Manage applications/devices:" -echo "------------------------------" -echo -echo "URL:" -echo " ${MGMT_URL}" +bold "Create an initial application and device:" +bold "------------------------------" echo -echo "Applications:" -echo " Create: drg create app app_id" -echo " Read: drg get app app_id" -echo " Edit: drg edit app app_id" -echo " Delete drg delete app app_id" +echo " drg create app app_id" +echo " drg create device --app app_id device_id --data '{\"credentials\": {\"credentials\":[{ \"pass\": \"foobar\" }]}}'" echo -echo "Devices:" -echo " Create: drg create device --app app_id device_id --data '{\"credentials\": {\"credentials\":[{ \"pass\": \"foobar\" }]}}'" -echo " Read: drg get device --app app_id device_id" -echo " Edit: drg edit device --app app_id device_id" -echo " Delete: drg delete device --app app_id device_id" +bold "Subscribe to device data:" +bold "---------------------------" echo -echo "Subscribe to device data:" -echo "---------------------------" -echo -echo "Data published by devices can be received via MQTT. Possibly start this in another terminal, having the access token set as shown before." +echo "Data published by devices can be received via MQTT. Possibly start this in another terminal." echo echo "Structured content mode (MQTT v3.1.1 and v5):" echo " mqtt sub -v -h $MQTT_INTEGRATION_HOST -p $MQTT_INTEGRATION_PORT -pw \"\$(drg token)\" -s --cafile build/certs/endpoints/ca-bundle.pem -t 'app/app_id'" @@ -85,37 +56,39 @@ echo echo "Binary content mode (MQTT v5 only):" echo " mqtt sub -v -h $MQTT_INTEGRATION_HOST -p $MQTT_INTEGRATION_PORT -pw \"\$(drg token)\" -s --cafile build/certs/endpoints/ca-bundle.pem -t 'app/app_id'" -up content-mode=binary echo -echo "Publish data:" -echo "---------------" +bold "Publish data:" +bold "---------------" echo echo "After you created a device, try these commands at a shell prompt:" echo -echo "System default certificates (or none):" -echo -echo " http --auth device_id@app_id:foobar POST $HTTP_ENDPOINT_URL/v1/foo temp:=42" -echo " mqtt pub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -s -t temp -m '{\"temp\":42}'" -echo -echo "Local test certificates:" -echo -echo " http --auth device_id@app_id:foobar --verify build/certs/endpoints/ca-bundle.pem POST $HTTP_ENDPOINT_URL/v1/foo temp:=42" -echo " mqtt pub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -s --cafile build/certs/endpoints/ca-bundle.pem -t temp -m '{\"temp\":42}'" -echo -echo "Send commands to the device:" -echo "------------------------------" +if test -f build/certs/endpoints/ca-bundle.pem; then + echo " http --auth device_id@app_id:foobar --verify build/certs/endpoints/ca-bundle.pem POST $HTTP_ENDPOINT_URL/v1/foo temp:=42" + echo " mqtt pub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -s --cafile build/certs/endpoints/ca-bundle.pem -t temp -m '{\"temp\":42}'" +else + echo " http --auth device_id@app_id:foobar POST $HTTP_ENDPOINT_URL/v1/foo temp:=42" + echo " mqtt pub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -s -t temp -m '{\"temp\":42}'" +fi echo -echo "After you created a device, try these commands at a shell prompt:" +bold "Send commands to the device:" +bold "------------------------------" echo -echo "Publish data from the device and specify how long will you wait for a command with 'ct' parameter (in seconds)" +echo "Publish data from the device and specify how long will you wait for a command with 'ct' parameter (in seconds):" echo -echo " http --auth device_id@app_id:foobar POST $HTTP_ENDPOINT_URL/v1/foo?ct=30 temp:=42" -echo " http --auth device_id@app_id:foobar --verify build/certs/endpoints/ca-bundle.pem POST $HTTP_ENDPOINT_URL/v1/foo?ct=30 temp:=42" +if test -f build/certs/endpoints/ca-bundle.pem; then + echo " http --auth device_id@app_id:foobar --verify build/certs/endpoints/ca-bundle.pem POST $HTTP_ENDPOINT_URL/v1/foo?ct=30 temp:=42" +else + echo " http --auth device_id@app_id:foobar POST $HTTP_ENDPOINT_URL/v1/foo?ct=30 temp:=42" +fi echo -echo "Or subscribe with the MQTT device" +echo "Or, subscribe with the MQTT device:" echo -echo " mqtt sub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -i device_id -s -t command/inbox" -echo " mqtt sub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -i device_id -s --cafile build/certs/endpoints/ca-bundle.pem -t command/inbox" +if test -f build/certs/endpoints/ca-bundle.pem; then + echo " mqtt sub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -i device_id -s --cafile build/certs/endpoints/ca-bundle.pem -t command/inbox" +else + echo " mqtt sub -v -h $MQTT_ENDPOINT_HOST -p $MQTT_ENDPOINT_PORT -u device_id@app_id -pw foobar -i device_id -s -t command/inbox" +fi echo -echo "Send command to that device from another terminal window:" +echo "Then, send a command to that device from another terminal window:" echo echo " http POST $COMMAND_ENDPOINT_URL/command application==app_id device==device_id command==set-temp target-temp:=25" \"Authorization:Bearer \$\(drg token\)\" echo