On Mon, Oct 19, 2020 at 04:17:16PM +0800, Wu Fengguang wrote:
On Fri, Oct 16, 2020 at 02:46:34PM +0800, Zhang Yale wrote:
Provide a login port for user by email, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale zhangyale3@huawei.com
daemon/sshd | 89 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 20 deletions(-)
diff --git a/daemon/sshd b/daemon/sshd index 98f31d77..55015b40 100755 --- a/daemon/sshd +++ b/daemon/sshd @@ -1,6 +1,16 @@ #!/bin/sh # pub_key
That variable is not used?
It's used in run_ssh().
email => my_email
Ok, I got it.
+# my_uuid
+# ssh_port_len +# ssh_port_base
上面的名字有误, 下面找不着.
I'm so sorry, I wrote it wrong in the following code. I'll fix and recommit.
+. $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=30000
30000 => 50000
Ok. I got it.
Thank, Yale
run_ssh() { @@ -11,40 +21,79 @@ run_ssh() systemctl start sshd }
-compose_email() +data_success() {
- deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S") data="To: $email
-Subject: [NOTIFY compass-ci] $testbox ready to ssh +Subject: [NOTIFY Compass-ci] $testbox ready to use
+Dear $my_name:
- Thanks for your participation in software ecosystem!
- According to your application, $testbox has been provisioned.
- The datails are as follows:
-Dear $email:
- Thanks for your participation in Kunpeng and software ecosystem!
- According to your application, $testbox has been provisioned.
- The datails are as follows:
- Login:
ssh root@api.compass-ci.openeuler.org -p $port
- Due time:
$deadline
- HW:
nr_cpu: $nr_cpu
memory: $memory
testbox: $testbox
- OS:
$os $os_version $os_arch
- Login:
ssh root@$PUB_IP
- Due time:
$deadline
+Regards +Compass-ci +" +}
+data_failure() +{
- data="To: $email
+Subject: [NOTIFY Compass-ci] Applying $testbox failed
- HW:
nr_cpu: $nr_cpu
memory: $memory
testbox: $testbox
- OS:
$os $os_version $os_arch
+Dear $my_name:
- Sorry to inform you that your application failed.
- You may need to wait for a while and then try again.
Regards -compass-ci +Compass-ci " }
+compose_email() +{
- deadline=$(date -d "+$runtime seconds" +"%Y-%m-%d %H:%M:%S")
- if [ -n "$port" ]; then
data_success
- else
data_failure
- fi
+}
+set_port() +{
- [ -n "$my_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 ] && return
- done
- port=""
+}
run_email() {
- [ -n "$email" ] || return 0
- [ -n "$email" ] && [ -n "$my_uuid" ] || return 0
- my_name=$(echo "$email" | awk -F '@' '{print $1}') compose_email
- curl -XPOST "$MAIL_HOST:$MAIL_PORT/send_mail_text" -d "$data"
- curl -XPOST "${MAIL_HOST:-$LKP_SERVER}:${MAIL_PORT:-11312}/send_mail_text" -d "$data"
}
run_ssh +set_port +report_ssh_port $port run_email -- 2.23.0