From 8c43deaa7a79fc9b8e35324e992d34693c0804ed Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Fri, 24 Apr 2020 12:43:56 -0700 Subject: [PATCH] Fix docker restapi start issue, undefined error (#4475) --- dockers/docker-sonic-restapi/restapi.sh | 5 ++++- rules/docker-restapi.mk | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dockers/docker-sonic-restapi/restapi.sh b/dockers/docker-sonic-restapi/restapi.sh index 61778e3245..d009507a7b 100755 --- a/dockers/docker-sonic-restapi/restapi.sh +++ b/dockers/docker-sonic-restapi/restapi.sh @@ -3,7 +3,10 @@ RESTAPI_ARGS="" while true do - client_auth=`sonic-cfggen -d -v "RESTAPI['config']['client_auth']"` + has_client_auth=$(sonic-cfggen -d -v "1 if RESTAPI and RESTAPI['config']") + if [ "$has_client_auth" == "1" ]; then + client_auth=$(sonic-cfggen -d -v "RESTAPI['config']['client_auth']") + fi if [[ $client_auth == 'true' ]]; then certs=`sonic-cfggen -d -v "RESTAPI['certs']"` allow_insecure=`sonic-cfggen -d -v "RESTAPI['config']['allow_insecure']"` diff --git a/rules/docker-restapi.mk b/rules/docker-restapi.mk index 09bbd03d8f..b472e00491 100644 --- a/rules/docker-restapi.mk +++ b/rules/docker-restapi.mk @@ -18,7 +18,6 @@ endif $(DOCKER_RESTAPI)_CONTAINER_NAME = restapi $(DOCKER_RESTAPI)_RUN_OPT += --cap-add NET_ADMIN --privileged -t -$(DOCKER_RESTAPI)_RUN_OPT += --network="host" $(DOCKER_RESTAPI)_RUN_OPT += -v /var/run/redis/redis.sock:/var/run/redis/redis.sock $(DOCKER_RESTAPI)_RUN_OPT += -v /etc/sonic/certificates:/etc/sonic/certificates:ro $(DOCKER_RESTAPI)_RUN_OPT += -p=8081:8081/tcp