Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale zhangyale3@huawei.com --- lib/forward_port.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 lib/forward_port.sh
diff --git a/lib/forward_port.sh b/lib/forward_port.sh new file mode 100755 index 00000000..7ebc8547 --- /dev/null +++ b/lib/forward_port.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 +[ -n "$sshr_port_len" ] || sshr_port_len=2000 +[ -n "$sshr_port_base" ] || sshr_port_base=50000 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%"$sshr_port_len"+"$sshr_port_base")) + ssh -o StrictHostKeyChecking=no \ + -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port" + break + done +} +