From 802e1f9ef59d38f337ca291df6bf1fb140ef7404 Mon Sep 17 00:00:00 2001 From: Todd Malsbary Date: Thu, 5 Nov 2020 09:40:31 -0800 Subject: [PATCH] Check for errors by default in scripts Inconsistent usage led to continuing after failure in, for example, kud_bm_deploy_mini when kud_bm_launch.sh failed to get the necessary packages. Scripts in ci, cmd/bpa-operator/vendor, deploy/kud-plugin-addons, and sdwan are excluded from this change. Issue-ID: ICN-498 Signed-off-by: Todd Malsbary Change-Id: Ib97fc73208e74115568974262ac2d213271fd649 --- cmd/bpa-operator/bpa_operator_launch.sh | 3 ++- cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh | 7 +++---- .../e2etest/bpa_remote_virtletvm_verifier.sh | 7 +++---- cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh | 3 ++- cmd/bpa-operator/e2etest/bpa_vm_verifier.sh | 7 +++---- cmd/bpa-restapi-agent/bpa_api_install.sh | 3 ++- cmd/bpa-restapi-agent/bpa_api_uninstall.sh | 3 ++- cmd/bpa-restapi-agent/e2e_test.sh | 3 ++- cmd/bpa-restapi-agent/install_go.sh | 3 ++- deploy/kud/kud_bm_launch.sh | 8 ++++---- deploy/kud/kud_launch.sh | 4 +++- deploy/metal3-vm/01_install_requirements.sh | 2 +- deploy/metal3-vm/02_configure_host.sh | 2 +- deploy/metal3-vm/03_launch_mgmt_cluster.sh | 4 ++-- deploy/metal3-vm/04_verify.sh | 7 ++----- deploy/metal3-vm/05_host_cleanup.sh | 5 ++++- .../metal3-vm/disable_apparmor_driver_libvirtd.sh | 1 + deploy/metal3-vm/lib/common.sh | 3 ++- deploy/metal3-vm/lib/logging.sh | 3 +++ .../ubuntu_bridge_network_configuration.sh | 3 +-- deploy/metal3-vm/ubuntu_install_requirements.sh | 2 +- .../vm-setup/roles/libvirt/files/get-domain-ip.sh | 5 ++--- .../vm-setup/roles/virtbmc/files/vbmc_start.sh | 3 ++- deploy/metal3/scripts/01_metal3.sh | 4 ++-- deploy/metal3/scripts/02_verify.sh | 7 ++----- deploy/metal3/scripts/03_verify_deprovisioning.sh | 9 +++------ env/cd_package_installer.sh | 2 +- env/lib/common.sh | 5 +++-- env/lib/logging.sh | 3 ++- env/metal3/01_install_package.sh | 11 ++++++----- env/metal3/02_configure.sh | 12 ++++++----- env/metal3/03_launch_prereq.sh | 23 +++++++++------------- env/metal3/06_host_cleanup.sh | 3 ++- .../bootloader-env/01_bootloader_package_req.sh | 2 +- .../02_clean_bootloader_package_req.sh | 2 +- tools/cloud-configs.sh | 5 +++-- tools/collect.sh | 4 +--- tools/create_usb_bootable.sh | 3 +-- tools/openness/eaa/build_image.sh | 3 +-- tools/openness/edgeapps/sample-app/build-images.sh | 3 +-- tools/setup_build_machine.sh | 1 + user_config.sh | 2 +- verify.sh | 1 + 43 files changed, 99 insertions(+), 97 deletions(-) diff --git a/cmd/bpa-operator/bpa_operator_launch.sh b/cmd/bpa-operator/bpa_operator_launch.sh index d1f1448..ae118d7 100755 --- a/cmd/bpa-operator/bpa_operator_launch.sh +++ b/cmd/bpa-operator/bpa_operator_launch.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail #Get Go ENV variables eval "$(go env)" diff --git a/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh b/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh index 5dece3a..edf93df 100755 --- a/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_bmh_verifier.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail CLUSTER_NAME=test-bmh-cluster @@ -25,9 +26,7 @@ then KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}') TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode ) - call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure - ret=$? - if [[ $ret != 0 ]]; + if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure; then printf "\nKubernetes Cluster Install did not complete successfully\n" else diff --git a/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh index 8f54d2f..78096b5 100755 --- a/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_remote_virtletvm_verifier.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail printf "\n\nStart Remote Virtlet VM provisioning E2E test\n\n" @@ -8,9 +9,7 @@ CLUSTER_NAME=bpa-remote KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}') TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode ) -call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure -ret=$? -if [[ $ret != 0 ]]; +if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure; then printf "\nRemote Kubernetes Cluster Install did not complete successfully\n" else diff --git a/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh index 3a45727..946a1f9 100755 --- a/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_virtletvm_verifier.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail printf "\n\nStart Virtlet VM provisioning E2E test\n\n" diff --git a/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh b/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh index 2d0ce08..e18de25 100755 --- a/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh +++ b/cmd/bpa-operator/e2etest/bpa_vm_verifier.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail CLUSTER_NAME=cluster-test @@ -84,9 +85,7 @@ then KUBECONFIG=--kubeconfig=/opt/kud/multi-cluster/${CLUSTER_NAME}/artifacts/admin.conf APISERVER=$(kubectl ${KUBECONFIG} config view --minify -o jsonpath='{.clusters[0].cluster.server}') TOKEN=$(kubectl ${KUBECONFIG} get secret $(kubectl ${KUBECONFIG} get serviceaccount default -o jsonpath='{.secrets[0].name}') -o jsonpath='{.data.token}' | base64 --decode ) - call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure - ret=$? - if [[ $ret != 0 ]]; + if ! call_api $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure; then printf "\nKubernetes Cluster Install did not complete successfully\n" else diff --git a/cmd/bpa-restapi-agent/bpa_api_install.sh b/cmd/bpa-restapi-agent/bpa_api_install.sh index 3b8428e..533bebd 100755 --- a/cmd/bpa-restapi-agent/bpa_api_install.sh +++ b/cmd/bpa-restapi-agent/bpa_api_install.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail ICN_DIR=$(dirname "$(dirname "$PWD")") diff --git a/cmd/bpa-restapi-agent/bpa_api_uninstall.sh b/cmd/bpa-restapi-agent/bpa_api_uninstall.sh index f1f8836..89748df 100755 --- a/cmd/bpa-restapi-agent/bpa_api_uninstall.sh +++ b/cmd/bpa-restapi-agent/bpa_api_uninstall.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail ICN_DIR=$(dirname "$(dirname "$PWD")") diff --git a/cmd/bpa-restapi-agent/e2e_test.sh b/cmd/bpa-restapi-agent/e2e_test.sh index 48c8f30..4742bdb 100755 --- a/cmd/bpa-restapi-agent/e2e_test.sh +++ b/cmd/bpa-restapi-agent/e2e_test.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail ICN_DIR=$(dirname "$(dirname "$PWD")") diff --git a/cmd/bpa-restapi-agent/install_go.sh b/cmd/bpa-restapi-agent/install_go.sh index 944a58b..e3341cb 100755 --- a/cmd/bpa-restapi-agent/install_go.sh +++ b/cmd/bpa-restapi-agent/install_go.sh @@ -1,4 +1,5 @@ -#1/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail if which go > /dev/null; then sudo apt-get -yq install golang-go diff --git a/deploy/kud/kud_bm_launch.sh b/deploy/kud/kud_bm_launch.sh index 2d0aea6..2e5f9aa 100755 --- a/deploy/kud/kud_bm_launch.sh +++ b/deploy/kud/kud_bm_launch.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set +x +#!/usr/bin/env bash +set -eu -o pipefail LIBDIR="$(dirname "$(dirname "$PWD")")" @@ -37,7 +37,7 @@ function set_bm_kud { pushd $DOWNLOAD_PATH/multicloud-k8s/kud/hosting_providers/vagrant/inventory HOST_IP=${HOST_IP:-$(hostname -I | cut -d ' ' -f 1)} if [ "$1" == "minimal" ] ; then - cat < hosts.ini + cat < hosts.ini [all] $HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 @@ -55,7 +55,7 @@ kube-node kube-master EOL else - cat < hosts.ini + cat < hosts.ini [all] $HOSTNAME ansible_ssh_host=${HOST_IP} ansible_ssh_port=22 diff --git a/deploy/kud/kud_launch.sh b/deploy/kud/kud_launch.sh index e63419a..53d7154 100755 --- a/deploy/kud/kud_launch.sh +++ b/deploy/kud/kud_launch.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail + LIBDIR="$(dirname "$(dirname "$PWD")")" source $LIBDIR/env/lib/common.sh diff --git a/deploy/metal3-vm/01_install_requirements.sh b/deploy/metal3-vm/01_install_requirements.sh index a2c0775..ca9ce6c 100755 --- a/deploy/metal3-vm/01_install_requirements.sh +++ b/deploy/metal3-vm/01_install_requirements.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set +x +set -eu -o pipefail OS=$(awk -F= '/^ID=/ { print $2 }' /etc/os-release | tr -d '"') if [[ $OS == ubuntu ]]; then diff --git a/deploy/metal3-vm/02_configure_host.sh b/deploy/metal3-vm/02_configure_host.sh index 80ee984..e99e8b5 100755 --- a/deploy/metal3-vm/02_configure_host.sh +++ b/deploy/metal3-vm/02_configure_host.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -xe +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh diff --git a/deploy/metal3-vm/03_launch_mgmt_cluster.sh b/deploy/metal3-vm/03_launch_mgmt_cluster.sh index d593380..0c3e707 100755 --- a/deploy/metal3-vm/03_launch_mgmt_cluster.sh +++ b/deploy/metal3-vm/03_launch_mgmt_cluster.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -xe +#!/usr/bin/env bash +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh diff --git a/deploy/metal3-vm/04_verify.sh b/deploy/metal3-vm/04_verify.sh index 0d6e5f2..ce42eba 100755 --- a/deploy/metal3-vm/04_verify.sh +++ b/deploy/metal3-vm/04_verify.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#set -x +set -eu -o pipefail # shellcheck disable=SC1091 source lib/common.sh @@ -47,15 +47,12 @@ function warm_up_time { } function wait_for_provisioned { - all_bmh_provisioned=1 declare -i k=1 declare -i t=$timeout while ((t > 0)); do echo "Try $k/$timeout iteration : Wait for $interval seconds to check all bmh state" sleep $interval - list_nodes | check_provisioned - all_bmh_state=$? - if [[ $all_bmh_state -eq $all_bmh_provisioned ]]; then + if ! list_nodes | check_provisioned; then echo "All the VMs are provisioned - success" warm_up_time exit 0 diff --git a/deploy/metal3-vm/05_host_cleanup.sh b/deploy/metal3-vm/05_host_cleanup.sh index 0c83b56..c8edd48 100755 --- a/deploy/metal3-vm/05_host_cleanup.sh +++ b/deploy/metal3-vm/05_host_cleanup.sh @@ -1,11 +1,14 @@ #!/usr/bin/env bash -set -x +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh # shellcheck disable=SC1091 source lib/common.sh +BMO_RUN_LOCAL="${BMO_RUN_LOCAL:-false}" +CAPBM_RUN_LOCAL="${CAPBM_RUN_LOCAL:-false}" + # Kill and remove the running ironic containers for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader; do sudo "${CONTAINER_RUNTIME}" ps | grep -w "$name$" && sudo "${CONTAINER_RUNTIME}" kill $name diff --git a/deploy/metal3-vm/disable_apparmor_driver_libvirtd.sh b/deploy/metal3-vm/disable_apparmor_driver_libvirtd.sh index 0c84350..5aca6d6 100644 --- a/deploy/metal3-vm/disable_apparmor_driver_libvirtd.sh +++ b/deploy/metal3-vm/disable_apparmor_driver_libvirtd.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -eu -o pipefail selinux="#security_driver = \"selinux\"" apparmor="security_driver = \"apparmor\"" diff --git a/deploy/metal3-vm/lib/common.sh b/deploy/metal3-vm/lib/common.sh index 034c243..6c82637 100644 --- a/deploy/metal3-vm/lib/common.sh +++ b/deploy/metal3-vm/lib/common.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail eval "$(go env)" diff --git a/deploy/metal3-vm/lib/logging.sh b/deploy/metal3-vm/lib/logging.sh index 0bef81a..e936439 100644 --- a/deploy/metal3-vm/lib/logging.sh +++ b/deploy/metal3-vm/lib/logging.sh @@ -1,3 +1,6 @@ +#!/usr/bin/env bash +set -eu -o pipefail + # Log output automatically LOGDIR="$(dirname $0)/logs" if [ ! -d "$LOGDIR" ]; then diff --git a/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh b/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh index dffa678..3f7b8b9 100755 --- a/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh +++ b/deploy/metal3-vm/ubuntu_bridge_network_configuration.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -xe +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh diff --git a/deploy/metal3-vm/ubuntu_install_requirements.sh b/deploy/metal3-vm/ubuntu_install_requirements.sh index 503813a..3886888 100755 --- a/deploy/metal3-vm/ubuntu_install_requirements.sh +++ b/deploy/metal3-vm/ubuntu_install_requirements.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail # shellcheck disable=SC1091 source lib/logging.sh diff --git a/deploy/metal3-vm/vm-setup/roles/libvirt/files/get-domain-ip.sh b/deploy/metal3-vm/vm-setup/roles/libvirt/files/get-domain-ip.sh index 8ccc078..ad0fd61 100644 --- a/deploy/metal3-vm/vm-setup/roles/libvirt/files/get-domain-ip.sh +++ b/deploy/metal3-vm/vm-setup/roles/libvirt/files/get-domain-ip.sh @@ -1,9 +1,8 @@ -#!/bin/sh +#!/usr/bin/env bash +set -eu -o pipefail # This script will attempt to get the ip address of the a given libvirt guest. -set -eu - PATH=$PATH:/usr/sbin:/sbin VMNAME=$1 diff --git a/deploy/metal3-vm/vm-setup/roles/virtbmc/files/vbmc_start.sh b/deploy/metal3-vm/vm-setup/roles/virtbmc/files/vbmc_start.sh index fa48a0c..651a9b0 100755 --- a/deploy/metal3-vm/vm-setup/roles/virtbmc/files/vbmc_start.sh +++ b/deploy/metal3-vm/vm-setup/roles/virtbmc/files/vbmc_start.sh @@ -1,4 +1,5 @@ -#!/bin/bash -x +#!/usr/bin/env bash +set -eux -o pipefail name="$1" diff --git a/deploy/metal3/scripts/01_metal3.sh b/deploy/metal3/scripts/01_metal3.sh index 08d8c76..dbfa2d3 100755 --- a/deploy/metal3/scripts/01_metal3.sh +++ b/deploy/metal3/scripts/01_metal3.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set +ex +#!/usr/bin/env bash +set -eu -o pipefail LIBDIR="$(dirname "$(dirname "$(dirname "$PWD")")")" diff --git a/deploy/metal3/scripts/02_verify.sh b/deploy/metal3/scripts/02_verify.sh index fff486b..85a2a29 100755 --- a/deploy/metal3/scripts/02_verify.sh +++ b/deploy/metal3/scripts/02_verify.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#set -x +set -eu -o pipefail LIBDIR="$(dirname "$(dirname "$(dirname "$PWD")")")" @@ -50,14 +50,11 @@ function warm_up_time { } function wait_for_provisioned { - all_bmh_provisioned=1 declare -i k=1 while ((timeout > 0)); do echo "Try $k iteration : Wait for $interval seconds to check all bmh state" sleep $interval - list_nodes | check_provisioned - all_bmh_state=$? - if [[ $all_bmh_state -eq $all_bmh_provisioned ]]; then + if ! list_nodes | check_provisioned; then echo "All the Baremetal hosts are provisioned - success" warm_up_time exit 0 diff --git a/deploy/metal3/scripts/03_verify_deprovisioning.sh b/deploy/metal3/scripts/03_verify_deprovisioning.sh index 97a8a21..afe0497 100755 --- a/deploy/metal3/scripts/03_verify_deprovisioning.sh +++ b/deploy/metal3/scripts/03_verify_deprovisioning.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#set -x +set -eu -o pipefail LIBDIR="$(dirname "$(dirname "$(dirname "$PWD")")")" @@ -26,7 +26,7 @@ function check_deprovisioned { echo "Baremetal $name current_host_state : "$current_host_state echo "Previous Baremetals prev_host_state : "$prev_host_state - if [ $j -eq 0 ]; then + if [ $j -eq 0 ]; then prev_host_state=$current_host_state ((j+=1)) continue @@ -50,14 +50,11 @@ function warm_up_time { } function wait_for_deprovisioned { - all_bmh_deprovisioned=1 declare -i k=1 while ((timeout > 0)); do echo "Try $k iteration : Wait for $interval seconds to check all bmh state" sleep $interval - list_nodes | check_deprovisioned - all_bmh_state=$? - if [[ $all_bmh_state -eq $all_bmh_deprovisioned ]]; then + if ! list_nodes | check_deprovisioned; then echo "All the Baremetal hosts are deprovisioned - success" warm_up_time exit 0 diff --git a/env/cd_package_installer.sh b/env/cd_package_installer.sh index 6370f01..e6641d6 100755 --- a/env/cd_package_installer.sh +++ b/env/cd_package_installer.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" diff --git a/env/lib/common.sh b/env/lib/common.sh index 195c807..39125ef 100755 --- a/env/lib/common.sh +++ b/env/lib/common.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail #supported OS version UBUNTU_BIONIC=${UBUNTU_BIONIC:-Ubuntu 18.04.2 LTS} @@ -8,7 +9,7 @@ DOWNLOAD_PATH=${DOWNLOAD_PATH:-/opt/icn} LOCAL_APT_REPO=${LOCAL_APT_REPO:-$DOWNLOAD_PATH/apt} PIP_CACHE_DIR=${PIP_CACHE_DIR:-$DOWNLOAD_PATH/pip-cache-dir} BUILD_DIR=${BUILD_DIR:-$DOWNLOAD_PATH/build-dir} -CONTAINER_IMAGES_DIR=${CONTAINER_IMAGES_DIR:-$OFFLINE_DOWNLOAD_PATH/docker-dir} +CONTAINER_IMAGES_DIR=${CONTAINER_IMAGES_DIR:-$DOWNLOAD_PATH/docker-dir} #set variables #Todo include over all variables here diff --git a/env/lib/logging.sh b/env/lib/logging.sh index 40a29f8..9f31833 100755 --- a/env/lib/logging.sh +++ b/env/lib/logging.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail # Log output automatically # referred from metal3 project diff --git a/env/metal3/01_install_package.sh b/env/metal3/01_install_package.sh index 56b65d3..bff8096 100755 --- a/env/metal3/01_install_package.sh +++ b/env/metal3/01_install_package.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail LIBDIR="$(dirname "$PWD")" @@ -112,9 +112,10 @@ install() { #install_kubernetes_packages $1 } -if ["$1" == "-o"]; then +if [ "$#" -eq 0 ]; then + install online +elif [ "$1" == "-o" ]; then install offline - exit 0 +else + exit 1 fi - -install diff --git a/env/metal3/02_configure.sh b/env/metal3/02_configure.sh index e05abc1..085a162 100755 --- a/env/metal3/02_configure.sh +++ b/env/metal3/02_configure.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -set -xe +set -eux -o pipefail + LIBDIR="$(dirname "$PWD")" source $LIBDIR/lib/logging.sh @@ -163,9 +164,10 @@ function configure { configure_ironic_interfaces } -if [ "$1" == "-o" ]; then +if [ "$#" -eq 0 ]; then + configure online +elif [ "$1" == "-o" ]; then configure offline - exit 0 +else + exit 1 fi - -configure diff --git a/env/metal3/03_launch_prereq.sh b/env/metal3/03_launch_prereq.sh index efd97c5..8b2b056 100755 --- a/env/metal3/03_launch_prereq.sh +++ b/env/metal3/03_launch_prereq.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -xe +#!/usr/bin/env bash +set -eux -o pipefail LIBDIR="$(dirname "$PWD")" @@ -182,23 +182,18 @@ function install { install_ironic_container } -if [ "$1" == "-o" ]; then +if [ "$#" -eq 0 ]; then + install online +elif [ "$1" == "-o" ]; then install offline - exit 0 -fi - -if [ "$1" == "--dhcp-start" ]; then +elif [ "$1" == "--dhcp-start" ]; then install_dhcp echo "wait for 320s for nodes to be assigned" sleep 6m - exit 0 -fi - -if [ "$1" == "--dhcp-reset" ]; then +elif [ "$1" == "--dhcp-reset" ]; then reset_dhcp echo "wait for 320s for nodes to be re-assigned" sleep 6m - exit 0 +else + exit 1 fi - -install diff --git a/env/metal3/06_host_cleanup.sh b/env/metal3/06_host_cleanup.sh index 4085718..f82636a 100755 --- a/env/metal3/06_host_cleanup.sh +++ b/env/metal3/06_host_cleanup.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -set -x +set -eux -o pipefail + LIBDIR="$(dirname "$PWD")" source $LIBDIR/lib/common.sh diff --git a/env/ubuntu/bootloader-env/01_bootloader_package_req.sh b/env/ubuntu/bootloader-env/01_bootloader_package_req.sh index 082d973..8bbb226 100755 --- a/env/ubuntu/bootloader-env/01_bootloader_package_req.sh +++ b/env/ubuntu/bootloader-env/01_bootloader_package_req.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail shopt -s extglob source $(dirname $PWD)/../lib/common.sh diff --git a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh index 9c20cf2..54c9ab3 100755 --- a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh +++ b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -ex +set -eux -o pipefail source $(dirname $PWD)/../lib/common.sh source $(dirname $PWD)/../lib/logging.sh diff --git a/tools/cloud-configs.sh b/tools/cloud-configs.sh index acce8c1..94857b8 100644 --- a/tools/cloud-configs.sh +++ b/tools/cloud-configs.sh @@ -1,4 +1,5 @@ -!/bin/bash +#!/usr/bin/env bash +set -eu -o pipefail # This script is called by cloud-init on worker nodes # What does this script do: @@ -25,7 +26,7 @@ for module in $MODULES_LIST; do tar xvzf $filename if [ -d $module ]; then echo "Installing module $module ..." - pushd $module + pushd $module bash ./install.sh popd rm -rf $module diff --git a/tools/collect.sh b/tools/collect.sh index 8351552..05450c2 100755 --- a/tools/collect.sh +++ b/tools/collect.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash - - -set -ex +set -eux -o pipefail SCRIPT_PATH=`realpath $0` TOOL_PATH=`dirname "$SCRIPT_PATH"` diff --git a/tools/create_usb_bootable.sh b/tools/create_usb_bootable.sh index ea64344..b493038 100755 --- a/tools/create_usb_bootable.sh +++ b/tools/create_usb_bootable.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -ex +set -eux -o pipefail SCRIPT_PATH=`realpath $0` TOOL_PATH=`dirname "$SCRIPT_PATH"` diff --git a/tools/openness/eaa/build_image.sh b/tools/openness/eaa/build_image.sh index 439fe8a..3a8acbd 100755 --- a/tools/openness/eaa/build_image.sh +++ b/tools/openness/eaa/build_image.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -ex +set -eux -o pipefail source ../_common.sh diff --git a/tools/openness/edgeapps/sample-app/build-images.sh b/tools/openness/edgeapps/sample-app/build-images.sh index 59c233d..a696a4a 100755 --- a/tools/openness/edgeapps/sample-app/build-images.sh +++ b/tools/openness/edgeapps/sample-app/build-images.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -ex +set -eux -o pipefail source ../../_common.sh diff --git a/tools/setup_build_machine.sh b/tools/setup_build_machine.sh index 293bff9..2d5f857 100755 --- a/tools/setup_build_machine.sh +++ b/tools/setup_build_machine.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -eu -o pipefail apt update apt install -y mkisofs coreutils diff --git a/user_config.sh b/user_config.sh index 42689fc..a6fac44 100644 --- a/user_config.sh +++ b/user_config.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash #Local controller - Bootstrap cluster DHCP connection export BS_DHCP_INTERFACE="eno3" diff --git a/verify.sh b/verify.sh index 328b892..9e63eeb 100755 --- a/verify.sh +++ b/verify.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -eu -o pipefail # This file is called by jenkins CI job -- 2.16.6