From edd49479f5a4a433ccaf4ebac4f00f32086b1960 Mon Sep 17 00:00:00 2001 From: TommyLike Date: Mon, 4 Nov 2019 14:21:49 +0800 Subject: [PATCH] Update jenkins slave scripts --- ci/slave-scripts/centos.sh | 43 +++++++++++++++++-- ci/slave-scripts/opensuse.sh | 40 +++++++++++++++-- ci/slave-scripts/setup.sh | 4 +- obs/tf/startup/README.md | 2 +- .../download_package_codes/projects_raw.xml | 2 +- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/ci/slave-scripts/centos.sh b/ci/slave-scripts/centos.sh index 912d2d3..1ff8f50 100644 --- a/ci/slave-scripts/centos.sh +++ b/ci/slave-scripts/centos.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash disk_name=$1 +frontend_host=$2 +backend_host=$3 if [[ ! -e ${disk_name} ]]; then echo "disk ${disk_name} not existed" @@ -12,13 +14,48 @@ if [[ ! -e ~/.ssh/authorized_keys ]]; then exit 1 fi +if [[ ! -e /etc/yum.repos.d/OSC.repo ]]; then + curl -o /etc/yum.repos.d/OSC.repo http://download.opensuse.org/repositories/openSUSE:/Tools/CentOS_7/openSUSE:Tools.repo +fi # install required tools sudo yum install -y java-1.8.0-openjdk sudo yum install -y git +sudo yum install -y expect +sudo yum install -y osc + +#update osc config file +if [[ ! -d /root/.config/osc ]];then + mkdir -p /root/.config/osc +fi + +if [[ -e /root/.config/osc/oscrc ]];then + rm /root/.config/osc/oscrc +fi +cd /root/.config/osc +curl -o oscrc https://openeuler.obs.cn-south-1.myhuaweicloud.com:443/infrastructure/oscrc + +sed -i "s/#no_verify = 1/no_verify = 1/g" /root/.config/osc/oscrc + +# update /etc/hosts +echo "Updating the cluster hosts info" +# update hosts info: +# 1. build.openeuler.org +if ! grep -q "build.openeuler.org" /etc/hosts; then + echo "${frontend_host} build.openeuler.org" >> /etc/hosts +else + sed -i -e "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} build.openeuler.org/${frontend_host} build.openeuler.org/g" /etc/hosts +fi +if ! grep -q "backend.openeuler.org" /etc/hosts; then + echo "${backend_host} backend.openeuler.org" >> /etc/hosts +else + sed -i -e "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} backend.openeuler.org/${backend_host} backend.openeuler.org/g" /etc/hosts +fi # prepare disk -mkfs.ext4 ${disk_name} -mkdir /jenkins_home -mount ${disk_name} /jenkins_home +if [[ ! -d /jenkins_home ]]; then + mkfs.ext4 ${disk_name} + mkdir /jenkins_home + mount ${disk_name} /jenkins_home +fi chmod 600 ~/.ssh/authorized_keys diff --git a/ci/slave-scripts/opensuse.sh b/ci/slave-scripts/opensuse.sh index b50ddb0..efb1733 100644 --- a/ci/slave-scripts/opensuse.sh +++ b/ci/slave-scripts/opensuse.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash disk_name=$1 +frontend_host=$2 +backend_host=$3 if [[ ! -e ${disk_name} ]]; then echo "disk ${disk_name} not existed" @@ -15,10 +17,42 @@ fi # install required tools zypper install -y java-1_8_0-openjdk zypper install -y git +zypper install -y osc +zypper install -y expect + +#update osc config file +if [[ ! -d /root/.config/osc ]];then + mkdir -p /root/.config/osc +fi + +if [[ -e /root/.config/osc/oscrc ]];then + rm /root/.config/osc/oscrc +fi +cd /root/.config/osc +curl -o oscrc https://openeuler.obs.cn-south-1.myhuaweicloud.com:443/infrastructure/oscrc +sed -i "s/#no_verify = 1/no_verify = 1/g" /root/.config/osc/oscrc + +# update /etc/hosts +echo "Updating the cluster hosts info" +# update hosts info: +# 1. build.openeuler.org +if ! grep -q "build.openeuler.org" /etc/hosts; then + echo "${frontend_host} build.openeuler.org" >> /etc/hosts +else + sed -i -e "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} build.openeuler.org/${frontend_host} build.openeuler.org/g" /etc/hosts +fi +if ! grep -q "backend.openeuler.org" /etc/hosts; then + echo "${backend_host} backend.openeuler.org" >> /etc/hosts +else + sed -i -e "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\} backend.openeuler.org/${backend_host} backend.openeuler.org/g" /etc/hosts +fi + # prepare disk -mkfs.ext4 ${disk_name} -mkdir /jenkins_home -mount ${disk_name} /jenkins_home +if [[ ! -d /jenkins_home ]]; then + mkfs.ext4 ${disk_name} + mkdir /jenkins_home + mount ${disk_name} /jenkins_home +fi chmod 600 ~/.ssh/authorized_keys diff --git a/ci/slave-scripts/setup.sh b/ci/slave-scripts/setup.sh index b4a1a0c..8344f46 100755 --- a/ci/slave-scripts/setup.sh +++ b/ci/slave-scripts/setup.sh @@ -4,6 +4,8 @@ script_name=$1 ip_address=$2 disk_name=$3 +frontend_name=$4 +backend_name=$5 scp ./authorized_keys root@${ip_address}:~/.ssh/ scp ./${script_name} root@${ip_address}:~/ -ssh root@${ip_address} "chmod +x ~/${script_name} && ~/${script_name} ${disk_name}" \ No newline at end of file +ssh root@${ip_address} "chmod +x ~/${script_name} && ~/${script_name} ${disk_name} ${frontend_name} ${backend_name}" diff --git a/obs/tf/startup/README.md b/obs/tf/startup/README.md index 97cf417..50e394e 100644 --- a/obs/tf/startup/README.md +++ b/obs/tf/startup/README.md @@ -123,7 +123,7 @@ Worker6: 172.16.1.195 Worker7: 172.16.1.127 Worker8: 172.16.1.12 Worker9: 172.16.1.14 -Worker10: 172.16.1.157 +Worker10: 172.16.1.57 ``` ## download full fedora packages diff --git a/obs/tf/startup/download_package_codes/projects_raw.xml b/obs/tf/startup/download_package_codes/projects_raw.xml index 1d1b658..701b762 100644 --- a/obs/tf/startup/download_package_codes/projects_raw.xml +++ b/obs/tf/startup/download_package_codes/projects_raw.xml @@ -657,7 +657,7 @@ - + -- GitLab