From a406c3d18f6de96e6b2e319164a0a964ad3a9b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BC=AA=E5=BC=80=E6=B3=A2?= Date: Tue, 6 Apr 2021 10:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!41=20:?= =?UTF-8?q?=20change=20release=20server=20ip=20and=20add=20port'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/make_version.sh | 4 ++-- script/setup_env.sh | 11 +---------- script/step/make_debug_everything.sh | 4 ++-- script/step/make_iso.sh | 4 ++-- script/step/make_iso_everysrc.sh | 4 ++-- script/step/make_iso_everything.sh | 4 ++-- script/tools/safe_sshcmd.sh | 12 +++--------- script/tools/sshcmd.sh | 24 +++++++----------------- script/tools/sshscp.sh | 3 ++- script/tools/util.sh | 6 +----- 10 files changed, 24 insertions(+), 52 deletions(-) diff --git a/script/make_version.sh b/script/make_version.sh index e9d1f69..d59b428 100644 --- a/script/make_version.sh +++ b/script/make_version.sh @@ -42,12 +42,12 @@ function get_repose() } for((i=0;i<3;i++)); do -ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa -p ${RELEASE_SERVER_PORT} root@${RELEASE_SERVER_IP} ip addr | grep "172." | tr -cd "[0-9].[0-9]/ " | awk '{print $3}' | awk -F "/" '{print $1}') +ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} ip addr | grep "172." | tr -cd "[0-9].[0-9]/ " | awk '{print $3}' | awk -F "/" '{print $1}') if [ "$ret" != "${RELEASE_SERVER_IP}" ];then break fi done -sed -i "s/RELEASE_SERVER_IP=\"${RELEASE_SERVER_IP}\"/RELEASE_SERVER_IP=\"$ret\"/g" "${BUILD_SCRIPT_DIR}"/setup_env.sh +#sed -i "s/RELEASE_SERVER_IP=\"${RELEASE_SERVER_IP}\"/RELEASE_SERVER_IP=\"$ret\"/g" "${BUILD_SCRIPT_DIR}"/setup_env.sh #sh "${BUILD_SCRIPT_DIR}"/tools/safe_sshcmd.sh -c "ip add | grep 172 | awk -F '/' '{print \$1}'| awk '{print \$2}'" -m ${RELEASE_SERVER_IP} -u "root" -p "xxxx" -t 120 -n 3 #if echo "${CI_PROJECT}" | grep '_gcov'; then # modify_for_gcov "${BUILD_SCRIPT_DIR}" diff --git a/script/setup_env.sh b/script/setup_env.sh index 291e6a7..6562cd9 100644 --- a/script/setup_env.sh +++ b/script/setup_env.sh @@ -10,8 +10,7 @@ export OS_VERSION="$(echo ${tmp//:/-})" export OBS_UI_IP="172.16.1.81" export OBS_SERVER_IP="172.16.1.95" -export RELEASE_SERVER_IP="172.16.1.241" -export RELEASE_SERVER_PORT="30322" +export RELEASE_SERVER_IP="172.17.4.28" export ARCH=$(uname -m) export RELEASE_HTTP_URL="http://121.36.84.172/dailybuild" @@ -87,11 +86,3 @@ EOF cat ${OBS_REPO_CONF} - -if [ -n "${RELEASE_SERVER_PORT}" ];then - export SSHPORT="-p ${RELEASE_SERVER_PORT}" - export SCPPORT="-P ${RELEASE_SERVER_PORT}" -else - export SSHPORT="" - export SCPPORT="" -fi diff --git a/script/step/make_debug_everything.sh b/script/step/make_debug_everything.sh index 7c2d499..8040b9c 100644 --- a/script/step/make_debug_everything.sh +++ b/script/step/make_debug_everything.sh @@ -78,10 +78,10 @@ function make_debug_everything_inchroot() sshcmd "${SSH_CMD}" sshscp "${TGZ_NAME} ${TGZ_NAME}${SHA256SUM}" "${RELEASE_DIR}" set +e - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) done SSH_CMD="mount -t iso9660 -o loop ${RELEASE_DIR}/${TGZ_NAME} ${MOUNT_DIR}" sshcmd "${SSH_CMD}" diff --git a/script/step/make_iso.sh b/script/step/make_iso.sh index d9ef36d..744ccc4 100644 --- a/script/step/make_iso.sh +++ b/script/step/make_iso.sh @@ -78,10 +78,10 @@ function make_iso_inchroot() sshcmd "${SSH_CMD}" sshscp "${TGZ_NAME} ${TGZ_NAME}${SHA256SUM} ${iso_rpmlist}" "${RELEASE_DIR}" set +e - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) done SSH_CMD="mount -t iso9660 -o loop ${RELEASE_DIR}/${TGZ_NAME} ${MOUNT_DIR}" sshcmd "${SSH_CMD}" diff --git a/script/step/make_iso_everysrc.sh b/script/step/make_iso_everysrc.sh index cc943c2..2db2a07 100644 --- a/script/step/make_iso_everysrc.sh +++ b/script/step/make_iso_everysrc.sh @@ -81,10 +81,10 @@ function make_iso_everysrc_inchroot() sshcmd "${SSH_CMD}" sshscp "${TGZ_NAME} ${TGZ_NAME}${SHA256SUM}" "${RELEASE_DIR}" set +e - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep source | awk '{print $3}') + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep source | awk '{print $3}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) done SSH_CMD="mkdir -p ${MOUNT_DIR}" sshcmd "${SSH_CMD}" diff --git a/script/step/make_iso_everything.sh b/script/step/make_iso_everything.sh index fd18c04..91519c5 100644 --- a/script/step/make_iso_everything.sh +++ b/script/step/make_iso_everything.sh @@ -83,10 +83,10 @@ function make_iso_everything_inchroot() sshcmd "${SSH_CMD}" sshscp "${TGZ_NAME} ${TGZ_NAME}${SHA256SUM}" "${RELEASE_DIR}" set +e - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep everything/${ARCH} | awk '{print $3}') + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep everything/${ARCH} | awk '{print $3}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) done SSH_CMD="mount -t iso9660 -o loop ${RELEASE_DIR}/${TGZ_NAME} ${MOUNT_DIR}" sshcmd "${SSH_CMD}" diff --git a/script/tools/safe_sshcmd.sh b/script/tools/safe_sshcmd.sh index e54dad7..7aea68e 100644 --- a/script/tools/safe_sshcmd.sh +++ b/script/tools/safe_sshcmd.sh @@ -4,7 +4,6 @@ set -e execcmd="" machineip="" -machineport="" loginuser=root loginpassword=huawei timeout=120 @@ -18,10 +17,10 @@ retry_cnt=3 ###################### function usage() { - echo "Usage: sshcmd.sh -c "command" -m "machinetip" [-P machineport] [-u login_user] [-p login_password] [-t ping_timeout] [-n ssh_retry_time]" + echo "Usage: sshcmd.sh -c "command" -m "machinetip" [-u login_user] [-p login_password] [-t ping_timeout] [-n ssh_retry_time]" } -while getopts "c:m:p:u:t:n:P:h" OPTIONS +while getopts "c:m:p:u:t:n:h" OPTIONS do case "${OPTIONS}" in c) execcmd="${OPTARG}";; @@ -30,7 +29,6 @@ do p) loginpassword="${OPTARG}";; t) timeout="${OPTARG}";; n) retry_cnt="${OPTARG}";; - P) machineport="${OPTARG}";; \?) echo "ERROR - Invalid parameter"; echo "ERROR - Invalid parameter" >&2;usage;exit 1;; *) echo "ERROR - Invalid parameter"; echo "ERROR - Invalid parameter" >&2; usage;exit 1;; esac @@ -44,11 +42,7 @@ fi for((i=0;i&2;usage;exit 1;; *) echo "ERROR - Invalid parameter"; echo "ERROR - Invalid parameter" >&2; usage;exit 1;; esac @@ -148,7 +138,7 @@ function delete_known_hosts() ###################### function usage() { - echo "Usage: sshcmd.sh -c "command" -m "machinetip" [-P machineport] [-u login_user] [-p login_password]" + echo "Usage: sshcmd.sh -c "command" -m "machinetip" [-u login_user] [-p login_password]" } if [ "x${execcmd}" = "x" -o "x${machineip}" = "x" ];then @@ -157,6 +147,6 @@ if [ "x${execcmd}" = "x" -o "x${machineip}" = "x" ];then fi delete_known_hosts -sshcmd_comm "${execcmd}" "${machineip}" "${loginpassword}" "${loginuser}" "${machineport}" +sshcmd_comm "${execcmd}" "${machineip}" "${loginpassword}" "${loginuser}" exit $? diff --git a/script/tools/sshscp.sh b/script/tools/sshscp.sh index 7be9432..5fd2106 100644 --- a/script/tools/sshscp.sh +++ b/script/tools/sshscp.sh @@ -35,12 +35,13 @@ function sshcmd_comm() else r_option="" fi + expect <<-END1 ## set infinite timeout, because some commands maybe execute long time. set timeout -1 ## remotly exectue command - spawn scp -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" ${SCPPORT} "${r_option}" "${srccommand}" "${descommand}" + spawn scp -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" "${r_option}" "${srccommand}" "${descommand}" expect { diff --git a/script/tools/util.sh b/script/tools/util.sh index 3b623ca..476f28b 100644 --- a/script/tools/util.sh +++ b/script/tools/util.sh @@ -56,11 +56,7 @@ function log_debug() ###################### function sshcmd() { - if [ -n "${RELEASE_SERVER_PORT}" ];then - sh "${BUILD_SCRIPT_DIR}/tools/safe_sshcmd.sh" -c "$1" -m "${RELEASE_SERVER_IP}" -t 120 -n 3 -P "${RELEASE_SERVER_PORT}" - else - sh "${BUILD_SCRIPT_DIR}/tools/safe_sshcmd.sh" -c "$1" -m "${RELEASE_SERVER_IP}" -t 120 -n 3 - fi + sh "${BUILD_SCRIPT_DIR}/tools/safe_sshcmd.sh" -c "$1" -m "${RELEASE_SERVER_IP}" -t 120 -n 3 #sh "${BUILD_SCRIPT_DIR}/tools/safe_sshcmd.sh" -c "$1" -m "${RELEASE_SERVER_IP}" -u "${USER}" -p "${PASSWD}" -t 120 -n 3 } -- Gitee