From 8e8d1d12e42b57797c1de4e2ea779186467fa3bc Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sat, 28 Apr 2018 05:51:46 +0000 Subject: [PATCH 1/4] [syncd]: Add socat and bcmsh wrapper Signed-off-by: Qi Luo --- platform/broadcom/docker-syncd-brcm/Dockerfile.j2 | 4 +++- platform/broadcom/docker-syncd-brcm/bcmsh | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 platform/broadcom/docker-syncd-brcm/bcmsh diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index 96ae65ee8897..c65274ae39a9 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -19,7 +19,9 @@ debs/{{ deb }}{{' '}} ## TODO: add kmod into Depends RUN apt-get install -f kmod -COPY ["files/dsserve", "files/bcmcmd", "start.sh", "/usr/bin/"] +RUN apt-get install socat + +COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] diff --git a/platform/broadcom/docker-syncd-brcm/bcmsh b/platform/broadcom/docker-syncd-brcm/bcmsh new file mode 100755 index 000000000000..71cf1095f239 --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm/bcmsh @@ -0,0 +1,3 @@ +#!/bin/bash +/usr/bin/socat - UNIX-CONNECT:/var/run/sswsyncd/sswsyncd.socket + From 9642547ee1c4f97a51847c541bd0fd4411b00cee Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sat, 28 Apr 2018 19:36:34 +0000 Subject: [PATCH 2/4] Install socat in docker-base Signed-off-by: Qi Luo --- dockers/docker-base/Dockerfile.j2 | 3 +++ platform/broadcom/docker-syncd-brcm/Dockerfile.j2 | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dockers/docker-base/Dockerfile.j2 b/dockers/docker-base/Dockerfile.j2 index db693540fb32..98f8237cee57 100644 --- a/dockers/docker-base/Dockerfile.j2 +++ b/dockers/docker-base/Dockerfile.j2 @@ -31,6 +31,9 @@ RUN apt-get -y install \ python \ less +# Pre-install troubleshooting packages +RUN apt-get -y install socat + COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] COPY ["root/.vimrc", "/root/.vimrc"] diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index c65274ae39a9..042e7e764fd1 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -19,8 +19,6 @@ debs/{{ deb }}{{' '}} ## TODO: add kmod into Depends RUN apt-get install -f kmod -RUN apt-get install socat - COPY ["files/dsserve", "files/bcmcmd", "start.sh", "bcmsh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd From 8674951b31e0e125cff6880c60497eb680cfe993 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 4 May 2018 01:57:18 +0000 Subject: [PATCH 3/4] Add hint banner, add host wrapper Signed-off-by: Qi Luo --- .../docker-syncd-brcm/base_image_files/bcmsh | 3 ++ platform/broadcom/docker-syncd-brcm/bcmsh | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 platform/broadcom/docker-syncd-brcm/base_image_files/bcmsh diff --git a/platform/broadcom/docker-syncd-brcm/base_image_files/bcmsh b/platform/broadcom/docker-syncd-brcm/base_image_files/bcmsh new file mode 100755 index 000000000000..c3a38742575d --- /dev/null +++ b/platform/broadcom/docker-syncd-brcm/base_image_files/bcmsh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker exec -i syncd bcmsh "$@" diff --git a/platform/broadcom/docker-syncd-brcm/bcmsh b/platform/broadcom/docker-syncd-brcm/bcmsh index 71cf1095f239..c5bd08b73251 100755 --- a/platform/broadcom/docker-syncd-brcm/bcmsh +++ b/platform/broadcom/docker-syncd-brcm/bcmsh @@ -1,3 +1,36 @@ #!/bin/bash +usage="$(basename "$0") [-h] [-q] -- interactive shell for bcm service + +where: + -h show this help text + -q quite, no banner (default: verbose)" + +banner="Press Enter to show prompt. +Press Ctrl+C to exit. +Run command 'exit' will shutdown bcm service. +" + +# Default verbose +quiet=false + +while getopts 'hq' option; do + case "$option" in + h) echo "$usage" + exit + ;; + q) quiet=true + ;; + \?) printf "illegal option: -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + esac +done +shift $((OPTIND - 1)) + +if [ "$quiet" = false ]; then + echo "$banner" +fi + /usr/bin/socat - UNIX-CONNECT:/var/run/sswsyncd/sswsyncd.socket From 28a541df23018322075f5dc44bcda99a767b2529 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 4 May 2018 05:57:48 +0000 Subject: [PATCH 4/4] Refine banner message Signed-off-by: Qi Luo --- platform/broadcom/docker-syncd-brcm/bcmsh | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/broadcom/docker-syncd-brcm/bcmsh b/platform/broadcom/docker-syncd-brcm/bcmsh index c5bd08b73251..7d2fa2f4d3c3 100755 --- a/platform/broadcom/docker-syncd-brcm/bcmsh +++ b/platform/broadcom/docker-syncd-brcm/bcmsh @@ -7,7 +7,6 @@ where: banner="Press Enter to show prompt. Press Ctrl+C to exit. -Run command 'exit' will shutdown bcm service. " # Default verbose