Skip to content

Commit ba6aba2

Browse files
authoredMay 23, 2023
[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>
1 parent f5d488d commit ba6aba2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎dockers/docker-sonic-mgmt-framework/rest-server.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ MGMT_VARS=${MGMT_VARS//[\']/\"}
1616
REST_SERVER=$(echo $MGMT_VARS | jq -r '.rest_server')
1717

1818
if [ -n "$REST_SERVER" ]; then
19-
SERVER_PORT=$(echo $REST_SERVER | jq -r '.port')
20-
CLIENT_AUTH=$(echo $REST_SERVER | jq -r '.client_auth')
21-
LOG_LEVEL=$(echo $REST_SERVER | jq -r '.log_level')
19+
SERVER_PORT=$(echo $REST_SERVER | jq -r '.port // empty')
20+
CLIENT_AUTH=$(echo $REST_SERVER | jq -r '.client_auth // empty')
21+
LOG_LEVEL=$(echo $REST_SERVER | jq -r '.log_level // empty')
2222

23-
SERVER_CRT=$(echo $REST_SERVER | jq -r '.server_crt')
24-
SERVER_KEY=$(echo $REST_SERVER | jq -r '.server_key')
25-
CA_CRT=$(echo $REST_SERVER | jq -r '.ca_crt')
23+
SERVER_CRT=$(echo $REST_SERVER | jq -r '.server_crt // empty')
24+
SERVER_KEY=$(echo $REST_SERVER | jq -r '.server_key // empty')
25+
CA_CRT=$(echo $REST_SERVER | jq -r '.ca_crt // empty')
2626
fi
2727

2828
if [[ -z $SERVER_CRT ]] && [[ -z $SERVER_KEY ]] && [[ -z $CA_CRT ]]; then
@@ -31,9 +31,9 @@ fi
3131

3232
# Read certificate file paths from DEVICE_METADATA|x509 entry.
3333
if [ -n "$X509" ]; then
34-
SERVER_CRT=$(echo $X509 | jq -r '.server_crt')
35-
SERVER_KEY=$(echo $X509 | jq -r '.server_key')
36-
CA_CRT=$(echo $X509 | jq -r '.ca_crt')
34+
SERVER_CRT=$(echo $X509 | jq -r '.server_crt // empty')
35+
SERVER_KEY=$(echo $X509 | jq -r '.server_key // empty')
36+
CA_CRT=$(echo $X509 | jq -r '.ca_crt // empty')
3737
fi
3838

3939
# Create temporary server certificate if they not configured in ConfigDB

0 commit comments

Comments
 (0)
Please sign in to comment.