diff --git a/reset_release_server_ip.sh b/reset_release_server_ip.sh new file mode 100644 index 0000000000000000000000000000000000000000..86ef1e0b5dde39afd5494a770d546725de6f1242 --- /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 d59b42837d8b7848a0543e1d6e76d2e987d7576f..3e34615d04a2c97f47ab16362b93d4bc667baae9 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 6562cd9210387621eea0cf2af615a6a584350950..53a764416d34d7a0c1f5c0b4a0b58f68f07312d0 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 8040b9cf6a2b648fef8ba1a0021def999f9d9ae0..7c2d49944c48ed794de672af4f862f264a267a73 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 744ccc4205eea217a88c0d11b7efa77b4b8c37d0..d9ef36d7220e5093264e4ed0e2b0e8470794189b 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 2db2a071f0bd4cc2f834f218205f19f2b3613259..cc943c2ac6f84b872660463f1b2edaa15c1e98c5 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 91519c5e813a14c2c82f59a7c12af72c7436149e..fd18c04aef3ba3e0bbc31c02b3f8d46b6741d020 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 2305b93b40e5b6aa6e3a277ab3cf3d0748113340..fa361d44c55962956935c3e1c896216472847798 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 8ab61678ae1b5688b0cbe665f6468a095ad61a37..ae8ad39b7eae3c7d3176f87ab9633b9c105a38bd 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 5fd21068fb8891b1ddbc8ae36f8e673d7f65a99b..cef0ea8fbf7df5ba2364a0083d03cd356054fa7c 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 {