From abd2ef8c84b09274ed814b7a920f695aa889131c Mon Sep 17 00:00:00 2001 From: Sergey Kolekonov Date: Tue, 10 Feb 2015 15:29:33 +0300 Subject: [PATCH] Improve shell scripts style Change-Id: I5a4b800262c6afff78cd021cae6f6f5bb596c49c --- config/apt-cacher/apt-cacher.sh | 4 +-- config/devstack/local.sh | 2 +- config/devstack/micro-osd.sh | 2 +- config/nodepool/scripts/prepare_ui.sh | 2 +- jenkins_job_builder/sahara-ci-check.yaml | 2 +- slave-scripts/functions.sh | 37 ++++++++++-------------- slave-scripts/gate-sahara-pep8-trunk.sh | 3 +- slave-scripts/gate-ui-tests.sh | 2 +- slave-scripts/integration-cleanup.sh | 8 ++--- 9 files changed, 29 insertions(+), 33 deletions(-) diff --git a/config/apt-cacher/apt-cacher.sh b/config/apt-cacher/apt-cacher.sh index b08ea6f9..f462a1d3 100755 --- a/config/apt-cacher/apt-cacher.sh +++ b/config/apt-cacher/apt-cacher.sh @@ -29,11 +29,11 @@ wget http://archive.cloudera.com/cm5/ubuntu/precise/amd64/cm/cloudera.list -O cm sed -i "s/http:\/\//http:\/\/${CACHE_IP}\:3142\//g" cdh.list cm.list sudo apt-get install apache2 -y -sudo echo -e "Alias /cdh-repo ${REPOLIST_DIR} +echo -e "Alias /cdh-repo ${REPOLIST_DIR} Order allow,deny Allow from all Options +Indexes -" > /etc/apache2/sites-available/repo.conf +" | sudo tee /etc/apache2/sites-available/repo.conf sudo a2ensite repo sudo service apache2 reload diff --git a/config/devstack/local.sh b/config/devstack/local.sh index 4cba2f01..8d48de7b 100644 --- a/config/devstack/local.sh +++ b/config/devstack/local.sh @@ -14,7 +14,7 @@ else exit 1 fi -if [[ `nova endpoints | grep neutron` != "" ]]; then +if [[ $(nova endpoints | grep neutron) != "" ]]; then USE_NEUTRON=true else USE_NEUTRON=false diff --git a/config/devstack/micro-osd.sh b/config/devstack/micro-osd.sh index 424f6bfb..65657b46 100644 --- a/config/devstack/micro-osd.sh +++ b/config/devstack/micro-osd.sh @@ -112,7 +112,7 @@ echo ceph osd tree sleep 5 sudo cp $DIR/ceph.conf /etc/ceph/ -CEPH_HEALTH=`ceph health` +CEPH_HEALTH=$(ceph health) if [ "$CEPH_HEALTH" == "HEALTH_OK" ]; then echo "Ceph is installed successfully and working OK." echo diff --git a/config/nodepool/scripts/prepare_ui.sh b/config/nodepool/scripts/prepare_ui.sh index 824acf1a..360f513d 100755 --- a/config/nodepool/scripts/prepare_ui.sh +++ b/config/nodepool/scripts/prepare_ui.sh @@ -11,7 +11,7 @@ #Repository for Openstack Dashboard #sudo add-apt-repository cloud-archive:havana -y -NETWORK=`ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' | awk -F . '{print $2}'` +NETWORK=$(ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' | awk -F . '{print $2}') if [ "$NETWORK" == "0" ]; then OPENSTACK_HOST="172.18.168.42" else diff --git a/jenkins_job_builder/sahara-ci-check.yaml b/jenkins_job_builder/sahara-ci-check.yaml index 28e8bf21..f906d1fb 100644 --- a/jenkins_job_builder/sahara-ci-check.yaml +++ b/jenkins_job_builder/sahara-ci-check.yaml @@ -11,7 +11,7 @@ builders: - gerrit-git-prep - - shell: "bash -x /opt/ci/jenkins-jobs/sahara-ci-syntax-check.sh" + - shell: "bash /opt/ci/jenkins-jobs/sahara-ci-syntax-check.sh" publishers: - console-log diff --git a/slave-scripts/functions.sh b/slave-scripts/functions.sh index 70b15ae9..47484ac1 100644 --- a/slave-scripts/functions.sh +++ b/slave-scripts/functions.sh @@ -4,11 +4,11 @@ TMP_LOG=/tmp/tox.log LOG_FILE=/tmp/tox_log.txt BUILD_ID=dontKill TIMEOUT=60 -export ADDR=`ifconfig eth0| awk -F ' *|:' '/inet addr/{print $4}'` +export ADDR=$(ifconfig eth0| awk -F ' *|:' '/inet addr/{print $4}') # This function determines Openstack host by checking internal address (second octet) check_openstack_host() { - NETWORK=`ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' | awk -F . '{print $2}'` + NETWORK=$(ifconfig eth0 | awk -F ' *|:' '/inet addr/{print $4}' | awk -F . '{print $2}') export OS_USERNAME=ci-user export OS_TENANT_NAME=ci export OS_PASSWORD=nova @@ -106,7 +106,7 @@ start_sahara() { sahara_bin=sahara-all fi sahara-db-manage --config-file $conf_path upgrade head - status=`echo $?` + status=$? if [[ "$status" != 0 ]] then echo "Command 'sahara-db-manage' failed" @@ -147,9 +147,8 @@ NEUTRON_ENABLED = $USE_NEUTRON INTERNAL_NEUTRON_NETWORK = 'private' JOB_LAUNCH_TIMEOUT = 15 HDFS_INITIALIZATION_TIMEOUT = 10 -" >> $test_conf_path - echo "[VANILLA] +[VANILLA] IMAGE_NAME = '$VANILLA_IMAGE' SKIP_ALL_TESTS_FOR_PLUGIN = $SKIP_ALL_TESTS_FOR_PLUGIN SKIP_CINDER_TEST = '$SKIP_CINDER_TEST' @@ -160,9 +159,8 @@ SKIP_SWIFT_TEST = $SKIP_SWIFT_TEST SKIP_SCALING_TEST = $SKIP_SCALING_TEST SKIP_TRANSIENT_CLUSTER_TEST = $SKIP_TRANSIENT_TEST ONLY_TRANSIENT_CLUSTER_TEST = $SKIP_ONLY_TRANSIENT_TEST -" >> $test_conf_path - echo "[VANILLA_TWO] +[VANILLA_TWO] IMAGE_NAME = '$VANILLA_TWO_IMAGE' SKIP_ALL_TESTS_FOR_PLUGIN = $SKIP_ALL_TESTS_FOR_PLUGIN SKIP_CINDER_TEST = '$SKIP_CINDER_TEST' @@ -201,17 +199,15 @@ SKIP_EDP_TEST = $SKIP_EDP_TEST SKIP_MAP_REDUCE_TEST = $SKIP_MAP_REDUCE_TEST SKIP_SWIFT_TEST = $SKIP_SWIFT_TEST SKIP_SCALING_TEST = $SKIP_SCALING_TEST -" >> $test_conf_path - echo "[HDP2] +[HDP2] IMAGE_NAME = '$HDP_TWO_IMAGE' SKIP_ALL_TESTS_FOR_PLUGIN = $SKIP_ALL_TESTS_FOR_PLUGIN SKIP_SCALING_TEST = $SKIP_SCALING_TEST SKIP_EDP_TEST = $SKIP_EDP_TEST SKIP_SWIFT_TEST = $SKIP_SWIFT_TEST -" >> $test_conf_path - echo "[CDH] +[CDH] IMAGE_NAME = '$CDH_IMAGE' SKIP_ALL_TESTS_FOR_PLUGIN = $SKIP_ALL_TESTS_FOR_PLUGIN SKIP_MAP_REDUCE_TEST = $SKIP_MAP_REDUCE_TEST @@ -221,9 +217,8 @@ SKIP_CINDER_TEST = $SKIP_CINDER_TEST SKIP_EDP_TEST = $SKIP_EDP_TEST CM_REPO_LIST_URL = 'http://$OPENSTACK_HOST/cdh-repo/cm.list' CDH_REPO_LIST_URL = 'http://$OPENSTACK_HOST/cdh-repo/cdh.list' -" >> $test_conf_path - echo "[SPARK] +[SPARK] IMAGE_NAME = '$SPARK_IMAGE' SKIP_ALL_TESTS_FOR_PLUGIN = $SKIP_ALL_TESTS_FOR_PLUGIN SKIP_EDP_TEST = $SKIP_EDP_TEST @@ -240,35 +235,35 @@ run_tests() { if [ "$ZUUL_BRANCH" == "stable/icehouse" ] then tox -e integration -- hdp --concurrency=1 - STATUS=`echo $?` + STATUS=$? else tox -e integration -- hdp1 --concurrency=1 - STATUS=`echo $?` + STATUS=$? fi ;; hdp2) tox -e integration -- hdp2 --concurrency=1 - STATUS=`echo $?` + STATUS=$? ;; vanilla1) tox -e integration -- vanilla1 --concurrency=1 - STATUS=`echo $?` + STATUS=$? ;; vanilla2) tox -e integration -- vanilla2 --concurrency=1 - STATUS=`echo $?` + STATUS=$? ;; transient) tox -e integration -- transient --concurrency=3 - STATUS=`echo $?` + STATUS=$? ;; cdh) tox -e integration -- cdh --concurrency=1 - STATUS=`echo $?` + STATUS=$? ;; spark) tox -e integration -- spark --concurrency=1 - STATUS=`echo $?` + STATUS=$? ;; esac fi diff --git a/slave-scripts/gate-sahara-pep8-trunk.sh b/slave-scripts/gate-sahara-pep8-trunk.sh index fb423b22..e90da245 100644 --- a/slave-scripts/gate-sahara-pep8-trunk.sh +++ b/slave-scripts/gate-sahara-pep8-trunk.sh @@ -6,7 +6,8 @@ set -o pipefail # replace hacking with master tarball sed -i '/^hacking/d' test-requirements.txt -echo -e "-f http://tarballs.openstack.org/hacking/hacking-master.tar.gz#egg=hacking-master\nhacking==master\n$(cat test-requirements.txt)" > test-requirements.txt +REQS=$(cat test-requirements.txt) +echo -e "-f http://tarballs.openstack.org/hacking/hacking-master.tar.gz#egg=hacking-master\nhacking==master\n${REQS}" > test-requirements.txt sed -i '/^ignore/d' tox.ini sed -ie 's/\(^exclude.*\)/\1,*sahara-ci-config*/' tox.ini diff --git a/slave-scripts/gate-ui-tests.sh b/slave-scripts/gate-ui-tests.sh index e748dc4f..055191b9 100644 --- a/slave-scripts/gate-ui-tests.sh +++ b/slave-scripts/gate-ui-tests.sh @@ -63,7 +63,7 @@ hadoop_version = '1.3.2' " >> $DASHBOARD_PATH/saharadashboard/tests/configs/config.conf cd $DASHBOARD_PATH && tox -e uitests -STATUS=`echo $?` +STATUS=$? glance image-delete $TEST_IMAGE exit $STATUS diff --git a/slave-scripts/integration-cleanup.sh b/slave-scripts/integration-cleanup.sh index db6f7c3b..d806b723 100644 --- a/slave-scripts/integration-cleanup.sh +++ b/slave-scripts/integration-cleanup.sh @@ -18,7 +18,7 @@ else fi if [ $JOB_TYPE == 'dib' ]; then PLUGIN=$(echo $PREV_JOB | awk -F '-' '{ print $4 }') - if [[ $PLUGIN =~ 'vanilla' ]]; then + if [[ $PLUGIN =~ vanilla ]]; then IMAGE_TYPE=$(echo $PREV_JOB | awk -F '-' '{ print $5 }') if [ "$IMAGE_TYPE" == "centos" ]; then os="cos" @@ -39,7 +39,7 @@ if [ $JOB_TYPE == 'dib' ]; then python cleanup.py cleanup .*$HOST-cos-1-$PREV_BUILD-hdp.* elif [ $PLUGIN == 'hdp_2' ]; then python cleanup.py cleanup-heat .*$HOST-cos-2-$PREV_BUILD-hdp-v2.* - elif [[ $PLUGIN =~ 'cdh' ]]; then + elif [[ $PLUGIN =~ cdh ]]; then IMAGE_TYPE=$(echo $PREV_JOB | awk -F '-' '{ print $5 }') if [ "$IMAGE_TYPE" == "centos" ]; then os="cos" @@ -58,7 +58,7 @@ else ENGINE=$(echo $PREV_JOB | awk -F '-' '{ print $4 }') JOB_TYPE=$(echo $PREV_JOB | awk -F '-' '{ print $5 }') HADOOP_VERSION=1 - if [[ $JOB_TYPE =~ 'vanilla' ]] + if [[ $JOB_TYPE =~ vanilla ]] then HADOOP_VERSION=$(echo $JOB_TYPE | awk -F '_' '{ print $2 }') if [ "$HADOOP_VERSION" == '1' ]; then @@ -80,7 +80,7 @@ else HADOOP_VERSION=2 JOB_TYPE=hdp-v2 fi - if [[ $JOB_TYPE =~ 'cdh' ]] + if [[ $JOB_TYPE =~ cdh ]] then os_version=$(echo $JOB_TYPE | awk -F '_' '{ print $2}') if [ "$os_version" == "centos" ]; then