[mgmt-framework] Fix rest-server startup script (#14979)

This script was using 'null' as default value for all optional fields
of REST_SERVER table -- due to incorrect use of 'jq -r' command.
Server was not coming up when REST_SERVER entry exists but some fields
were not given (which is a valid configuration).
Fixed the jq query expression to return empty string for non existing
fields.

Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
This commit is contained in:
Sachin Holla 2023-05-23 06:12:38 +05:30 committed by GitHub
parent f5d488dd49
commit ba6aba2b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,13 +16,13 @@ MGMT_VARS=${MGMT_VARS//[\']/\"}
REST_SERVER=$(echo $MGMT_VARS | jq -r '.rest_server') REST_SERVER=$(echo $MGMT_VARS | jq -r '.rest_server')
if [ -n "$REST_SERVER" ]; then if [ -n "$REST_SERVER" ]; then
SERVER_PORT=$(echo $REST_SERVER | jq -r '.port') SERVER_PORT=$(echo $REST_SERVER | jq -r '.port // empty')
CLIENT_AUTH=$(echo $REST_SERVER | jq -r '.client_auth') CLIENT_AUTH=$(echo $REST_SERVER | jq -r '.client_auth // empty')
LOG_LEVEL=$(echo $REST_SERVER | jq -r '.log_level') LOG_LEVEL=$(echo $REST_SERVER | jq -r '.log_level // empty')
SERVER_CRT=$(echo $REST_SERVER | jq -r '.server_crt') SERVER_CRT=$(echo $REST_SERVER | jq -r '.server_crt // empty')
SERVER_KEY=$(echo $REST_SERVER | jq -r '.server_key') SERVER_KEY=$(echo $REST_SERVER | jq -r '.server_key // empty')
CA_CRT=$(echo $REST_SERVER | jq -r '.ca_crt') CA_CRT=$(echo $REST_SERVER | jq -r '.ca_crt // empty')
fi fi
if [[ -z $SERVER_CRT ]] && [[ -z $SERVER_KEY ]] && [[ -z $CA_CRT ]]; then if [[ -z $SERVER_CRT ]] && [[ -z $SERVER_KEY ]] && [[ -z $CA_CRT ]]; then
@ -31,9 +31,9 @@ fi
# Read certificate file paths from DEVICE_METADATA|x509 entry. # Read certificate file paths from DEVICE_METADATA|x509 entry.
if [ -n "$X509" ]; then if [ -n "$X509" ]; then
SERVER_CRT=$(echo $X509 | jq -r '.server_crt') SERVER_CRT=$(echo $X509 | jq -r '.server_crt // empty')
SERVER_KEY=$(echo $X509 | jq -r '.server_key') SERVER_KEY=$(echo $X509 | jq -r '.server_key // empty')
CA_CRT=$(echo $X509 | jq -r '.ca_crt') CA_CRT=$(echo $X509 | jq -r '.ca_crt // empty')
fi fi
# Create temporary server certificate if they not configured in ConfigDB # Create temporary server certificate if they not configured in ConfigDB