[bcmsh]: add inactivity timeout for bcmsh (default 300 seconds) (#1921)
Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
parent
9047edc38e
commit
859d0e1e8a
@ -1,24 +1,29 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
usage="$(basename "$0") [-h] [-q] -- interactive shell for bcm service
|
usage="$(basename "$0") [-h] [-q] [-t timeout] -- interactive shell for bcm service
|
||||||
|
|
||||||
where:
|
where:
|
||||||
-h show this help text
|
-h show this help text
|
||||||
|
-t inactivity timeout in seconds (default 300 seconds, 0 for no timeout)
|
||||||
-q quite, no banner (default: verbose)"
|
-q quite, no banner (default: verbose)"
|
||||||
|
|
||||||
banner="Press Enter to show prompt.
|
banner="Press Enter to show prompt.
|
||||||
Press Ctrl+C to exit.
|
Press Ctrl+C to exit.
|
||||||
|
NOTICE: Only one bcmsh or bcmcmd can connect to the shell at same time.
|
||||||
"
|
"
|
||||||
|
|
||||||
# Default verbose
|
# Default verbose
|
||||||
quiet=false
|
quiet=false
|
||||||
|
timeout=300
|
||||||
|
|
||||||
while getopts 'hq' option; do
|
while getopts 'hqt:' option; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
h) echo "$usage"
|
h) echo "$usage"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
q) quiet=true
|
q) quiet=true
|
||||||
;;
|
;;
|
||||||
|
t) timeout=$OPTARG
|
||||||
|
;;
|
||||||
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
|
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
|
||||||
echo "$usage" >&2
|
echo "$usage" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -31,5 +36,5 @@ if [ "$quiet" = false ]; then
|
|||||||
echo "$banner"
|
echo "$banner"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/bin/socat readline UNIX-CONNECT:/var/run/sswsyncd/sswsyncd.socket
|
/usr/bin/socat -T$timeout readline UNIX-CONNECT:/var/run/sswsyncd/sswsyncd.socket
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user