From afcd52db6f753a96848fcd23cbaa6381a5c09250 Mon Sep 17 00:00:00 2001 From: miao_kaibo Date: Tue, 6 Apr 2021 15:54:48 +0800 Subject: [PATCH] update release server ip --- reset_release_server_ip.sh | 3 +++ script/make_version.sh | 20 ---------------- script/setup_env.sh | 10 +++++++- 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/common.sh | 34 ++++++++++++++++++++++++++++ script/tools/sshcmd.sh | 2 +- script/tools/sshscp.sh | 2 +- 10 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 reset_release_server_ip.sh diff --git a/reset_release_server_ip.sh b/reset_release_server_ip.sh new file mode 100644 index 0000000..86ef1e0 --- /dev/null +++ b/reset_release_server_ip.sh @@ -0,0 +1,3 @@ +source script/tools/common.sh +source script/setup_env.sh +replace_release_server_ip diff --git a/script/make_version.sh b/script/make_version.sh index d59b428..3e34615 100644 --- a/script/make_version.sh +++ b/script/make_version.sh @@ -28,26 +28,6 @@ source "${BUILD_SCRIPT_DIR}"/tools/common.sh || exit 1 source "${BUILD_SCRIPT_DIR}"/tools/chroot.sh || exit 1 #source "${BUILD_SCRIPT_DIR}"/tools/obs.sh || exit 1 -function get_repose() -{ - expect -c " - spawn $* - expect { - \"*yes/no*\" {send \"yes\n\"} - eof - } - catch wait result; - exit [lindex \$result 3] - " -} -for((i=0;i<3;i++)); -do -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 #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 6562cd9..53a7644 100644 --- a/script/setup_env.sh +++ b/script/setup_env.sh @@ -10,7 +10,15 @@ 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.17.4.28" +export RELEASE_SERVER_IP="172.16.1.241" +export RELEASE_SERVER_PORT="30322" +if [ -n "${RELEASE_SERVER_PORT}" ];then + export SSHPORT="-p ${RELEASE_SERVER_PORT}" + export SCPPORT="-P ${RELEASE_SERVER_PORT}" +else + export SSHPORT="" + export SCPPORT="" +fi export ARCH=$(uname -m) export RELEASE_HTTP_URL="http://121.36.84.172/dailybuild" diff --git a/script/step/make_debug_everything.sh b/script/step/make_debug_everything.sh index 8040b9c..7c2d499 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 root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') + 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}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} 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 744ccc4..d9ef36d 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 root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep OS/${ARCH} | awk '{print $3}') + 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}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} 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 2db2a07..cc943c2 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 root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep source | awk '{print $3}') + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} 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 root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} 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 91519c5..fd18c04 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 root@${RELEASE_SERVER_IP} mount | grep ${RELEASE_VERSION_DIR} | grep everything/${ARCH} | awk '{print $3}') + 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}') for mp in $ret do - ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa root@${RELEASE_SERVER_IP} umount $mp) + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} 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/common.sh b/script/tools/common.sh index 2305b93..fa361d4 100644 --- a/script/tools/common.sh +++ b/script/tools/common.sh @@ -90,3 +90,37 @@ function trigger_jenkins_project() fi eval "${CMD}" } + +function get_repose() +{ + expect -c " + spawn $* + expect { + \"*yes/no*\" {send \"yes\n\"} + eof + } + catch wait result; + exit [lindex \$result 3] + " +} + +function replace_release_server_ip() +{ + if [ -n ${RELEASE_SERVER_PORT} ];then + SSHPORT="-p ${RELEASE_SERVER_PORT}" + else + SSHPORT="" + fi + setupfile=`find -iname "setup_env.sh"` + for((i=0;i<3;i++)); + do + ret=$(get_repose ssh -i ~/.ssh/super_publish_rsa ${SSHPORT} root@${RELEASE_SERVER_IP} ip addr | grep inet | awk '{print $2}' | grep -v '127' | awk -F '/' '{print $1}' | sed -n '1p') + if [ -n "$ret" ];then + sed -i "s/RELEASE_SERVER_IP=\"${RELEASE_SERVER_IP}\"/RELEASE_SERVER_IP=\"$ret\"/g" ${setupfile} + if [ "$ret" != "${RELEASE_SERVER_IP}" ];then + sed -i "s/RELEASE_SERVER_PORT=\"${RELEASE_SERVER_PORT}\"/RELEASE_SERVER_PORT=""/g" ${setupfile} + fi + break + fi + done +} diff --git a/script/tools/sshcmd.sh b/script/tools/sshcmd.sh index 8ab6167..ae8ad39 100644 --- a/script/tools/sshcmd.sh +++ b/script/tools/sshcmd.sh @@ -46,7 +46,7 @@ function sshcmd_comm() set timeout -1 ## remotly exectue command - spawn ssh -o "ConnectTimeout ${timeout}" -i ~/.ssh/super_publish_rsa "${user}@${testip}" "${cmd}" + spawn ssh -o "ConnectTimeout ${timeout}" -i ~/.ssh/super_publish_rsa ${SSHPORT} "${user}@${testip}" "${cmd}" expect { diff --git a/script/tools/sshscp.sh b/script/tools/sshscp.sh index 5fd2106..cef0ea8 100644 --- a/script/tools/sshscp.sh +++ b/script/tools/sshscp.sh @@ -41,7 +41,7 @@ function sshcmd_comm() set timeout -1 ## remotly exectue command - spawn scp -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" "${r_option}" "${srccommand}" "${descommand}" + spawn scp -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" ${SCPPORT} "${r_option}" "${srccommand}" "${descommand}" expect { -- Gitee