diff --git a/elements/apt-conf/extra-data.d/99-override-default-apt-conf b/elements/apt-conf/extra-data.d/99-override-default-apt-conf index 662b618b..02df80ce 100755 --- a/elements/apt-conf/extra-data.d/99-override-default-apt-conf +++ b/elements/apt-conf/extra-data.d/99-override-default-apt-conf @@ -2,6 +2,7 @@ # Override the default /etc/apt/apt.conf with $DIB_APT_CONF set -ue +set -o pipefail # exit directly if DIB_APT_CONF is not defined properly if [ -z "${DIB_APT_CONF:-}" ] ; then diff --git a/elements/apt-sources/extra-data.d/99-override-default-apt-sources b/elements/apt-sources/extra-data.d/99-override-default-apt-sources index e89cd5f9..0c8ae185 100755 --- a/elements/apt-sources/extra-data.d/99-override-default-apt-sources +++ b/elements/apt-sources/extra-data.d/99-override-default-apt-sources @@ -1,7 +1,8 @@ #!/bin/bash # Override the default /etc/apt/sources.list with $DIB_APT_SOURCES -set -e +set -eu +set -o pipefail # exit directly if DIB_APT_SOURCES is not defined properly if [ -z "$DIB_APT_SOURCES" ] ; then diff --git a/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk b/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk index 2622ae7f..6c136577 100755 --- a/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk +++ b/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk @@ -14,7 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/base/cleanup.d/01-ccache b/elements/base/cleanup.d/01-ccache index fd23437a..543736e1 100755 --- a/elements/base/cleanup.d/01-ccache +++ b/elements/base/cleanup.d/01-ccache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # As this is run in cleanup, it's already been automatically unmounted, # so all we need to do here is remove the directory diff --git a/elements/base/dib-first-boot b/elements/base/dib-first-boot index 1e39860b..7d9e2f98 100755 --- a/elements/base/dib-first-boot +++ b/elements/base/dib-first-boot @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail set -o xtrace touch /var/log/first-boot.d.log diff --git a/elements/base/dib-init-system b/elements/base/dib-init-system index 88cf5fae..3338f87e 100755 --- a/elements/base/dib-init-system +++ b/elements/base/dib-init-system @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail if [ -f /sbin/initctl ]; then echo "upstart" diff --git a/elements/base/extra-data.d/50-store-build-settings b/elements/base/extra-data.d/50-store-build-settings index 09ed73d6..20b50a3e 100755 --- a/elements/base/extra-data.d/50-store-build-settings +++ b/elements/base/extra-data.d/50-store-build-settings @@ -1,7 +1,9 @@ #!/bin/bash # Store the build-time environment and command line arguments -set -e +set -eu +set -o pipefail + source $_LIB/die [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" diff --git a/elements/base/extra-data.d/99-enable-install-types b/elements/base/extra-data.d/99-enable-install-types index 2b5c262a..8fdae7ed 100755 --- a/elements/base/extra-data.d/99-enable-install-types +++ b/elements/base/extra-data.d/99-enable-install-types @@ -15,6 +15,7 @@ set -eux +set -o pipefail declare -a SPECIFIED_ELEMS diff --git a/elements/base/finalise.d/01-install-dib-first-boot b/elements/base/finalise.d/01-install-dib-first-boot index 39e544d4..37bac737 100755 --- a/elements/base/finalise.d/01-install-dib-first-boot +++ b/elements/base/finalise.d/01-install-dib-first-boot @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail if [ -d /etc/first-boot.d ]; then install -m 0755 -o root -g root $(dirname $0)/../dib-first-boot /usr/sbin/ diff --git a/elements/base/install.d/00-baseline-environment b/elements/base/install.d/00-baseline-environment index 13b28df5..449f5096 100755 --- a/elements/base/install.d/00-baseline-environment +++ b/elements/base/install.d/00-baseline-environment @@ -1,6 +1,7 @@ #!/bin/bash # These are useful, or at worst not harmful, for all images we build. -set -e +set -eu +set -o pipefail install-packages vlan open-iscsi diff --git a/elements/base/install.d/10-cloud-init b/elements/base/install.d/10-cloud-init index f4eefa67..17b1c4b8 100755 --- a/elements/base/install.d/10-cloud-init +++ b/elements/base/install.d/10-cloud-init @@ -1,7 +1,8 @@ #!/bin/bash # Tweak the stock ubuntu cloud-init config -set -e +set -eu +set -o pipefail dd of=/etc/cloud/cloud.cfg.d/10_etc_hosts.cfg << EOF manage_etc_hosts: True diff --git a/elements/base/install.d/50-store-build-settings b/elements/base/install.d/50-store-build-settings index bb267912..8c11aa38 100755 --- a/elements/base/install.d/50-store-build-settings +++ b/elements/base/install.d/50-store-build-settings @@ -1,7 +1,8 @@ #!/bin/bash # Store build-time environment and command line arguments -set -e +set -eu +set -o pipefail if [ -e "/tmp/in_target.d/dib_environment" ]; then cp /tmp/in_target.d/dib_environment /etc/ diff --git a/elements/base/pre-install.d/03-baseline-tools b/elements/base/pre-install.d/03-baseline-tools index d2bcd6c0..39361da3 100755 --- a/elements/base/pre-install.d/03-baseline-tools +++ b/elements/base/pre-install.d/03-baseline-tools @@ -1,7 +1,8 @@ #!/bin/bash # Install baseline packages and tools. -set -e +set -eu +set -o pipefail # If lsb_release is missing, just do nothing. DISTRO=`lsb_release -si` || true diff --git a/elements/base/pre-install.d/04-dib-init-system b/elements/base/pre-install.d/04-dib-init-system index 54ea2587..aea564b2 100755 --- a/elements/base/pre-install.d/04-dib-init-system +++ b/elements/base/pre-install.d/04-dib-init-system @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail install -m 0755 -o root -g root $(dirname $0)/../dib-init-system /usr/bin/ diff --git a/elements/base/root.d/01-ccache b/elements/base/root.d/01-ccache index 2bad4646..67b7e250 100755 --- a/elements/base/root.d/01-ccache +++ b/elements/base/root.d/01-ccache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # Don't do anything if already mounted (if disk-image-create is invoked with # no elements specified, this hook actually fires twice, once during diff --git a/elements/cache-url/bin/cache-url b/elements/cache-url/bin/cache-url index 37aff537..f37e3212 100755 --- a/elements/cache-url/bin/cache-url +++ b/elements/cache-url/bin/cache-url @@ -15,7 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. -set -e +set -eu +set -o pipefail # Download a URL to a local cache # e.g. cache-url http://.../foo ~/.cache/image-create/foo diff --git a/elements/debian-systemd/root.d/05-debian-systemd b/elements/debian-systemd/root.d/05-debian-systemd index 0a37a306..3cafeb10 100755 --- a/elements/debian-systemd/root.d/05-debian-systemd +++ b/elements/debian-systemd/root.d/05-debian-systemd @@ -1,5 +1,6 @@ #!/bin/bash set -eux +set -o pipefail cat > ${TARGET_ROOT}/.extra_settings << EOF DIB_DEBIAN_ALT_INIT_PACKAGE=systemd-sysv EOF diff --git a/elements/debian-upstart/root.d/05-debian-upstart b/elements/debian-upstart/root.d/05-debian-upstart index 32eb199b..e400af32 100755 --- a/elements/debian-upstart/root.d/05-debian-upstart +++ b/elements/debian-upstart/root.d/05-debian-upstart @@ -1,5 +1,7 @@ #!/bin/bash set -eux +set -o pipefail + cat > ${TARGET_ROOT}/.extra_settings << EOF DIB_DEBIAN_ALT_INIT_PACKAGE=upstart EOF diff --git a/elements/debian-upstart/root.d/20-debian-fix-upstart-jobs b/elements/debian-upstart/root.d/20-debian-fix-upstart-jobs index 1ea1eb4b..877a7c14 100755 --- a/elements/debian-upstart/root.d/20-debian-fix-upstart-jobs +++ b/elements/debian-upstart/root.d/20-debian-fix-upstart-jobs @@ -1,5 +1,6 @@ #!/bin/bash set -eux +set -o pipefail # Working around bug in Debian cloud-init packages with upstart # where startpar will wait forever for these because they are tasks # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735204 diff --git a/elements/debian/root.d/08-debootstrap b/elements/debian/root.d/08-debootstrap index 5170a70b..ca9fa89e 100755 --- a/elements/debian/root.d/08-debootstrap +++ b/elements/debian/root.d/08-debootstrap @@ -15,6 +15,7 @@ # under the License. # set -eu +set -o pipefail if [ -f ${TARGET_ROOT}/.extra_settings ] ; then . ${TARGET_ROOT}/.extra_settings fi diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh index 37a324b4..0c9b7a77 100755 --- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh +++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail INTERFACE=${1:-} #optional, if not specified configure all available interfaces ENI_FILE="/etc/network/interfaces" @@ -68,7 +69,7 @@ function config_exists() { return 0 fi else - ifquery $interface >/dev/null 2>&1 && return 0 + ifquery $interface >/dev/null 2>&1 && return 0 || return 1 fi return 1 } diff --git a/elements/dib-run-parts/bin/dib-run-parts b/elements/dib-run-parts/bin/dib-run-parts index c2028a7d..c2a4e5e4 100755 --- a/elements/dib-run-parts/bin/dib-run-parts +++ b/elements/dib-run-parts/bin/dib-run-parts @@ -19,6 +19,7 @@ allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"} show_list= set -ue +set -o pipefail name=$(basename $0) diff --git a/elements/dib-run-parts/root.d/90-base-dib-run-parts b/elements/dib-run-parts/root.d/90-base-dib-run-parts index 7d502857..98d52b9b 100755 --- a/elements/dib-run-parts/root.d/90-base-dib-run-parts +++ b/elements/dib-run-parts/root.d/90-base-dib-run-parts @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -eu set -o pipefail home=$(dirname $0) diff --git a/elements/dpkg/bin/install-packages b/elements/dpkg/bin/install-packages index 800ce37f..285bf267 100755 --- a/elements/dpkg/bin/install-packages +++ b/elements/dpkg/bin/install-packages @@ -14,7 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -set -e +set -eu +set -o pipefail # install-packages package [package ...] diff --git a/elements/dpkg/cleanup.d/40-unblock-daemons b/elements/dpkg/cleanup.d/40-unblock-daemons index 7d50f1f4..b9712fd3 100755 --- a/elements/dpkg/cleanup.d/40-unblock-daemons +++ b/elements/dpkg/cleanup.d/40-unblock-daemons @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/dpkg/cleanup.d/50-remove-img-build-proxy b/elements/dpkg/cleanup.d/50-remove-img-build-proxy index 3a27b68e..096b13ea 100755 --- a/elements/dpkg/cleanup.d/50-remove-img-build-proxy +++ b/elements/dpkg/cleanup.d/50-remove-img-build-proxy @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/dpkg/post-install.d/99-clean-up-cache b/elements/dpkg/post-install.d/99-clean-up-cache index 2457f78d..8046c8a0 100755 --- a/elements/dpkg/post-install.d/99-clean-up-cache +++ b/elements/dpkg/post-install.d/99-clean-up-cache @@ -1,6 +1,7 @@ #!/bin/bash # Do an apt-get clean. This will free some space. -set -e +set -eu +set -o pipefail apt-get clean diff --git a/elements/dpkg/post-install.d/99-write-dpkg-manifest b/elements/dpkg/post-install.d/99-write-dpkg-manifest index 22473a75..6750e63d 100755 --- a/elements/dpkg/post-install.d/99-write-dpkg-manifest +++ b/elements/dpkg/post-install.d/99-write-dpkg-manifest @@ -15,6 +15,7 @@ # under the License. # set -eux +set -o pipefail DPKG_MANIFEST_NAME=dib-manifest-dpkg-$(basename ${IMAGE_NAME}) diff --git a/elements/dpkg/pre-install.d/99-apt-get-update b/elements/dpkg/pre-install.d/99-apt-get-update index 21238678..ab846154 100755 --- a/elements/dpkg/pre-install.d/99-apt-get-update +++ b/elements/dpkg/pre-install.d/99-apt-get-update @@ -1,6 +1,7 @@ #!/bin/bash # Do an apt-get update, so that packages can be installed. -set -e +set -eu +set -o pipefail apt-get -y update diff --git a/elements/dpkg/root.d/50-build-with-http-cache b/elements/dpkg/root.d/50-build-with-http-cache index 28cedd2d..5ba1e889 100755 --- a/elements/dpkg/root.d/50-build-with-http-cache +++ b/elements/dpkg/root.d/50-build-with-http-cache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/dpkg/root.d/60-block-apt-translations b/elements/dpkg/root.d/60-block-apt-translations index 77a640cc..4fde777d 100755 --- a/elements/dpkg/root.d/60-block-apt-translations +++ b/elements/dpkg/root.d/60-block-apt-translations @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/dpkg/root.d/99-block-daemons b/elements/dpkg/root.d/99-block-daemons index 57d9992c..4663013f 100755 --- a/elements/dpkg/root.d/99-block-daemons +++ b/elements/dpkg/root.d/99-block-daemons @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/dracut-network/install.d/10-install-dracut-network b/elements/dracut-network/install.d/10-install-dracut-network index 71bfe23a..c01f26ea 100755 --- a/elements/dracut-network/install.d/10-install-dracut-network +++ b/elements/dracut-network/install.d/10-install-dracut-network @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail install-packages dracut-network patch diff --git a/elements/fedora/root.d/10-fedora-cloud-image b/elements/fedora/root.d/10-fedora-cloud-image index 47abc17e..cc203087 100755 --- a/elements/fedora/root.d/10-fedora-cloud-image +++ b/elements/fedora/root.d/10-fedora-cloud-image @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] diff --git a/elements/hwdiscovery/install.d/10-hwinfo b/elements/hwdiscovery/install.d/10-hwinfo index baf74b63..21588eaa 100755 --- a/elements/hwdiscovery/install.d/10-hwinfo +++ b/elements/hwdiscovery/install.d/10-hwinfo @@ -1,7 +1,8 @@ #!/bin/bash # Support for hard ware discovery -set -e +set -eu +set -o pipefail set -o xtrace install-packages hwinfo diff --git a/elements/local-config/extra-data.d/62-ssh-key b/elements/local-config/extra-data.d/62-ssh-key index a6ad5dc8..f2d0d218 100755 --- a/elements/local-config/extra-data.d/62-ssh-key +++ b/elements/local-config/extra-data.d/62-ssh-key @@ -2,7 +2,9 @@ # Save user SSH public key if available. # (Obviously not suitable for downloadable images). -set -e +set -eu +set -o pipefail + source $_LIB/die [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" diff --git a/elements/local-config/install.d/62-ssh-key b/elements/local-config/install.d/62-ssh-key index 544162ec..cbdb92c6 100755 --- a/elements/local-config/install.d/62-ssh-key +++ b/elements/local-config/install.d/62-ssh-key @@ -2,7 +2,8 @@ # Save user SSH public key if available. # XXX: Obviously not suitable for downloadable images. -set -e +set -eu +set -o pipefail if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then mkdir -p /root/.ssh diff --git a/elements/local-config/pre-install.d/02-proxy-settings b/elements/local-config/pre-install.d/02-proxy-settings index 15afdb3f..cd05ce8f 100755 --- a/elements/local-config/pre-install.d/02-proxy-settings +++ b/elements/local-config/pre-install.d/02-proxy-settings @@ -2,7 +2,8 @@ # Save the HTTP/[S] and noproxy settings if available. # XXX: Obviously not suitable for downloadable images. -set -e +set -eu +set -o pipefail set -o xtrace have_apt= diff --git a/elements/manifests/cleanup.d/01-copy-manifests-dir b/elements/manifests/cleanup.d/01-copy-manifests-dir index fd78541b..a805bb3c 100755 --- a/elements/manifests/cleanup.d/01-copy-manifests-dir +++ b/elements/manifests/cleanup.d/01-copy-manifests-dir @@ -15,6 +15,7 @@ # under the License. # set -eux +set -o pipefail if [ -d $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} ]; then # Move the dib_environment and dib_arguments files into the manifests dir diff --git a/elements/manifests/environment.d/15-manifests b/elements/manifests/environment.d/15-manifests index 063cd6ca..89b817e8 100755 --- a/elements/manifests/environment.d/15-manifests +++ b/elements/manifests/environment.d/15-manifests @@ -15,6 +15,7 @@ # under the License. # set -eu +set -o pipefail export DIB_MANIFEST_IMAGE_DIR=${DIB_MANIFEST_IMAGE_DIR:-/etc/dib-manifests} export DIB_MANIFEST_SAVE_DIR=${DIB_MANIFEST_SAVE_DIR:-${IMAGE_NAME}.d/} diff --git a/elements/manifests/extra-data.d/20-manifest-dir b/elements/manifests/extra-data.d/20-manifest-dir index efdcb90a..d40f0b6a 100755 --- a/elements/manifests/extra-data.d/20-manifest-dir +++ b/elements/manifests/extra-data.d/20-manifest-dir @@ -15,5 +15,6 @@ # under the License. # set -eux +set -o pipefail sudo mkdir -p $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} diff --git a/elements/mellanox/install.d/65-mellanox b/elements/mellanox/install.d/65-mellanox index e35b9278..1df3ea77 100755 --- a/elements/mellanox/install.d/65-mellanox +++ b/elements/mellanox/install.d/65-mellanox @@ -1,7 +1,8 @@ #!/bin/bash # Ensure we load the mellanox driver somehow -set -e +set -eu +set -o pipefail home=$(dirname $0) diff --git a/elements/modprobe-blacklist/install.d/80-modprobe-blacklist b/elements/modprobe-blacklist/install.d/80-modprobe-blacklist index f787d016..3a844420 100755 --- a/elements/modprobe-blacklist/install.d/80-modprobe-blacklist +++ b/elements/modprobe-blacklist/install.d/80-modprobe-blacklist @@ -1,5 +1,6 @@ #!/bin/bash -set -ex +set -eux +set -o pipefail MODULES_LIST=${DIB_MODPROBE_BLACKLIST:?"Please set DIB_MODPROBE_BLACKLIST."} diff --git a/elements/opensuse/bin/install-packages b/elements/opensuse/bin/install-packages index 6d8a66ac..7585d308 100755 --- a/elements/opensuse/bin/install-packages +++ b/elements/opensuse/bin/install-packages @@ -14,7 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -set -e +set -eu +set -o pipefail function run_zypper() { # TODO: Uncertain if this can ever block wanting input from user diff --git a/elements/opensuse/extra-data.d/01-inject-defaults b/elements/opensuse/extra-data.d/01-inject-defaults index d07abd06..10204000 100755 --- a/elements/opensuse/extra-data.d/01-inject-defaults +++ b/elements/opensuse/extra-data.d/01-inject-defaults @@ -1,7 +1,7 @@ #!/bin/bash -set -e -set -x +set -eux +set -o pipefail export OPENSUSE_EXTRAS_PATH="$TMP_MOUNT_PATH/tmp/opensuse-extras" mkdir -p $OPENSUSE_EXTRAS_PATH diff --git a/elements/opensuse/install.d/01-ccache-symlinks b/elements/opensuse/install.d/01-ccache-symlinks index 2b14c6c9..c5883988 100755 --- a/elements/opensuse/install.d/01-ccache-symlinks +++ b/elements/opensuse/install.d/01-ccache-symlinks @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # Setup ccache symlinks, as openSUSE's ccache package doesn't # include them. diff --git a/elements/opensuse/install.d/01-login-defs b/elements/opensuse/install.d/01-login-defs index 9dd567fa..90329bd8 100755 --- a/elements/opensuse/install.d/01-login-defs +++ b/elements/opensuse/install.d/01-login-defs @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail sed -i -e "s,^USERGROUPS_ENAB.*$,USERGROUPS_ENAB yes," /etc/login.defs diff --git a/elements/opensuse/post-install.d/10-mkinitrd b/elements/opensuse/post-install.d/10-mkinitrd index 1c7b234d..476d8f0a 100755 --- a/elements/opensuse/post-install.d/10-mkinitrd +++ b/elements/opensuse/post-install.d/10-mkinitrd @@ -3,6 +3,7 @@ # here. set -eu +set -o pipefail # To have access to FS_TYPE _LIB="/tmp/opensuse-extras" diff --git a/elements/opensuse/root.d/10-opensuse-cloud-image b/elements/opensuse/root.d/10-opensuse-cloud-image index a57ac3b3..074ff544 100755 --- a/elements/opensuse/root.d/10-opensuse-cloud-image +++ b/elements/opensuse/root.d/10-opensuse-cloud-image @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] diff --git a/elements/pip-cache/root.d/01-pip-cache b/elements/pip-cache/root.d/01-pip-cache index aecbdc27..c3e37bdd 100755 --- a/elements/pip-cache/root.d/01-pip-cache +++ b/elements/pip-cache/root.d/01-pip-cache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail PIP_CACHE_DIR=$HOME/.cache/image-create/pip mkdir -p $PIP_CACHE_DIR diff --git a/elements/pypi/extra-data.d/00-mount-pypi-mirror b/elements/pypi/extra-data.d/00-mount-pypi-mirror index 6cc12534..5784c62b 100755 --- a/elements/pypi/extra-data.d/00-mount-pypi-mirror +++ b/elements/pypi/extra-data.d/00-mount-pypi-mirror @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''} if [ -n "$PYPI_MIRROR_URL" ]; then diff --git a/elements/pypi/post-install.d/00-unconfigure-pypi-mirror b/elements/pypi/post-install.d/00-unconfigure-pypi-mirror index 10054383..e0289d45 100755 --- a/elements/pypi/post-install.d/00-unconfigure-pypi-mirror +++ b/elements/pypi/post-install.d/00-unconfigure-pypi-mirror @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail if [ -e ~/.pip/pip.conf.orig ]; then mv ~/.pip/pip.conf{.orig,} diff --git a/elements/ramdisk/cleanup.d/99-extract-ramdisk-files b/elements/ramdisk/cleanup.d/99-extract-ramdisk-files index 85cfa1d1..ed57f76c 100755 --- a/elements/ramdisk/cleanup.d/99-extract-ramdisk-files +++ b/elements/ramdisk/cleanup.d/99-extract-ramdisk-files @@ -1,7 +1,7 @@ #!/bin/bash -set -e -set -x +set -eux +set -o pipefail IMAGE_NAME=${IMAGE_NAME:-'image'} diff --git a/elements/ramdisk/extra-data.d/01-inject-ramdisk-build-files b/elements/ramdisk/extra-data.d/01-inject-ramdisk-build-files index d9240f75..e0ee3e2a 100755 --- a/elements/ramdisk/extra-data.d/01-inject-ramdisk-build-files +++ b/elements/ramdisk/extra-data.d/01-inject-ramdisk-build-files @@ -1,7 +1,7 @@ #!/bin/bash -set -e -set -x +set -eux +set -o pipefail export RAMDISK_BUILD_PATH="$TMP_MOUNT_PATH/tmp/ramdisk-build" mkdir -p $RAMDISK_BUILD_PATH diff --git a/elements/ramdisk/install.d/20-install-dhcp-client b/elements/ramdisk/install.d/20-install-dhcp-client index db03d1fe..5b52bc1a 100755 --- a/elements/ramdisk/install.d/20-install-dhcp-client +++ b/elements/ramdisk/install.d/20-install-dhcp-client @@ -1,5 +1,6 @@ #!/bin/bash set -eux +set -o pipefail DISTRO=`lsb_release -si` || true diff --git a/elements/ramdisk/post-install.d/01-ensure-binaries b/elements/ramdisk/post-install.d/01-ensure-binaries index c6297b67..88417e22 100755 --- a/elements/ramdisk/post-install.d/01-ensure-binaries +++ b/elements/ramdisk/post-install.d/01-ensure-binaries @@ -1,8 +1,8 @@ #!/bin/bash # Ensure that all binaries listed in ramdisk elements, exist -set -e -set -x +set -eux +set -o pipefail export TARGET_DIR="/tmp/in_target.d/" diff --git a/elements/ramdisk/post-install.d/99-build-ramdisk b/elements/ramdisk/post-install.d/99-build-ramdisk index 49110f06..61a37379 100755 --- a/elements/ramdisk/post-install.d/99-build-ramdisk +++ b/elements/ramdisk/post-install.d/99-build-ramdisk @@ -1,7 +1,7 @@ #!/bin/bash -set -e -set -x +set -eux +set -o pipefail _LIB="/tmp/ramdisk-build" diff --git a/elements/redhat-common/bin/extract-image b/elements/redhat-common/bin/extract-image index 3a216b0e..db812610 100755 --- a/elements/redhat-common/bin/extract-image +++ b/elements/redhat-common/bin/extract-image @@ -5,6 +5,7 @@ set -eu +set -o pipefail BASE_IMAGE_FILE=$1 BASE_IMAGE_TAR=$2 diff --git a/elements/redhat-common/finalise.d/99-cleanup-tmp-grub b/elements/redhat-common/finalise.d/99-cleanup-tmp-grub index a2065bf2..ace72f09 100755 --- a/elements/redhat-common/finalise.d/99-cleanup-tmp-grub +++ b/elements/redhat-common/finalise.d/99-cleanup-tmp-grub @@ -1,5 +1,6 @@ #!/bin/bash set -eux +set -o pipefail rm -rf /tmp/grub diff --git a/elements/redhat-common/finalise.d/99-setup-first-boot b/elements/redhat-common/finalise.d/99-setup-first-boot index 7e787059..516d1b5b 100755 --- a/elements/redhat-common/finalise.d/99-setup-first-boot +++ b/elements/redhat-common/finalise.d/99-setup-first-boot @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail if [ -d /etc/first-boot.d ]; then rc_local=/etc/rc.d/rc.local diff --git a/elements/redhat-common/pre-install.d/02-lsb b/elements/redhat-common/pre-install.d/02-lsb index d4fb1f3d..f3eed2c1 100755 --- a/elements/redhat-common/pre-install.d/02-lsb +++ b/elements/redhat-common/pre-install.d/02-lsb @@ -1,5 +1,6 @@ #!/bin/bash set -eu +set -o pipefail install -m 0755 -o root -g root /opt/stack/lsb-release/lsb_release /usr/local/bin \ No newline at end of file diff --git a/elements/redhat-common/pre-install.d/15-remove-grub b/elements/redhat-common/pre-install.d/15-remove-grub index dd3e9830..3958baaf 100755 --- a/elements/redhat-common/pre-install.d/15-remove-grub +++ b/elements/redhat-common/pre-install.d/15-remove-grub @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail yum remove -y grub2 # Install grub2 dependencies to minimise packages installed during finalise. diff --git a/elements/rhel/finalise.d/60-rhsm-unregister b/elements/rhel/finalise.d/60-rhsm-unregister index e00da853..3ec367f4 100755 --- a/elements/rhel/finalise.d/60-rhsm-unregister +++ b/elements/rhel/finalise.d/60-rhsm-unregister @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]; then if [[ "$DIB_REG_TYPE" == "rhn" ]]; then diff --git a/elements/rhel/pre-install.d/00-rhsm b/elements/rhel/pre-install.d/00-rhsm index a3338161..17efd239 100755 --- a/elements/rhel/pre-install.d/00-rhsm +++ b/elements/rhel/pre-install.d/00-rhsm @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] then diff --git a/elements/rhel/root.d/10-rhel-cloud-image b/elements/rhel/root.d/10-rhel-cloud-image index 56d11930..9f4c24fb 100755 --- a/elements/rhel/root.d/10-rhel-cloud-image +++ b/elements/rhel/root.d/10-rhel-cloud-image @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] diff --git a/elements/rhel7/root.d/10-rhel-cloud-image b/elements/rhel7/root.d/10-rhel-cloud-image index 6a53a721..33127a28 100755 --- a/elements/rhel7/root.d/10-rhel-cloud-image +++ b/elements/rhel7/root.d/10-rhel-cloud-image @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] diff --git a/elements/rpm-distro/pre-install.d/01-override-yum-arch b/elements/rpm-distro/pre-install.d/01-override-yum-arch index 78f783a1..74ab9bb9 100755 --- a/elements/rpm-distro/pre-install.d/01-override-yum-arch +++ b/elements/rpm-distro/pre-install.d/01-override-yum-arch @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -eu set -o pipefail if [ "i386" = "$ARCH" ]; then diff --git a/elements/serial-console/install.d/20-stty b/elements/serial-console/install.d/20-stty index 57e6312e..cd69811d 100755 --- a/elements/serial-console/install.d/20-stty +++ b/elements/serial-console/install.d/20-stty @@ -1,5 +1,6 @@ #!/bin/bash set -uex +set -o pipefail SCRIPTDIR=$(dirname $0) DIB_INIT_SYSTEM=$(dib-init-system) diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index 56b8ae48..168beb78 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail # If the old cache exists, move it to the new name function make_new_cache(){ diff --git a/elements/source-repositories/install.d/01-source-repositories b/elements/source-repositories/install.d/01-source-repositories index 4ef606a7..47d37891 100755 --- a/elements/source-repositories/install.d/01-source-repositories +++ b/elements/source-repositories/install.d/01-source-repositories @@ -1,6 +1,7 @@ #!/bin/bash set -uex +set -o pipefail # Git isn't a dependency of this element, but is a dependency of pbr # if you are doing pip install on a git cloned directoy, because this diff --git a/elements/ubuntu/finalise.d/99-setup-first-boot b/elements/ubuntu/finalise.d/99-setup-first-boot index 4529d819..e147244a 100755 --- a/elements/ubuntu/finalise.d/99-setup-first-boot +++ b/elements/ubuntu/finalise.d/99-setup-first-boot @@ -1,5 +1,6 @@ #!/bin/bash -set -e +set -eu +set -o pipefail if [ -d /etc/first-boot.d ]; then rc_local=/etc/rc.local diff --git a/elements/ubuntu/install.d/10-support-physical-hardware b/elements/ubuntu/install.d/10-support-physical-hardware index 5120c826..08d4d543 100755 --- a/elements/ubuntu/install.d/10-support-physical-hardware +++ b/elements/ubuntu/install.d/10-support-physical-hardware @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # Ubuntu's cloud images don't include drivers for real hardware. install-packages linux-image-generic diff --git a/elements/ubuntu/pre-install.d/00-remove-grub b/elements/ubuntu/pre-install.d/00-remove-grub index 399e7b22..76f1d0c2 100755 --- a/elements/ubuntu/pre-install.d/00-remove-grub +++ b/elements/ubuntu/pre-install.d/00-remove-grub @@ -3,7 +3,8 @@ # found (as happens in a chroot). # Temporarily remove grub, to avoid that confusion. -set -e +set -eu +set -o pipefail if dpkg-query -W grub-pc; then apt-get -y remove grub-pc diff --git a/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror b/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror index a1b36494..5c1c7546 100755 --- a/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror +++ b/elements/ubuntu/pre-install.d/01-set-ubuntu-mirror @@ -1,6 +1,7 @@ #!/bin/bash set -eu +set -o pipefail DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} diff --git a/elements/ubuntu/root.d/10-cache-ubuntu-tarball b/elements/ubuntu/root.d/10-cache-ubuntu-tarball index 3bb17457..ebef6470 100755 --- a/elements/ubuntu/root.d/10-cache-ubuntu-tarball +++ b/elements/ubuntu/root.d/10-cache-ubuntu-tarball @@ -2,6 +2,7 @@ # These are useful, or at worst not harmful, for all images we build. set -eu +set -o pipefail [ -n "$ARCH" ] [ -n "$TARGET_ROOT" ] diff --git a/elements/vm/block-device.d/10-partition b/elements/vm/block-device.d/10-partition index 10c8dc17..2608e004 100755 --- a/elements/vm/block-device.d/10-partition +++ b/elements/vm/block-device.d/10-partition @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail source $_LIB/die [ -n "$IMAGE_BLOCK_DEVICE" ] || die "Image block device not set" diff --git a/elements/vm/finalise.d/50-remove-bogus-udev-links b/elements/vm/finalise.d/50-remove-bogus-udev-links index 879880aa..a0cd6cef 100755 --- a/elements/vm/finalise.d/50-remove-bogus-udev-links +++ b/elements/vm/finalise.d/50-remove-bogus-udev-links @@ -1,6 +1,7 @@ #!/bin/bash set -eux +set -o pipefail if [ "openSUSE project" = "$(lsb_release -is)" ]; then # workaround for https://bugzilla.novell.com/show_bug.cgi?id=859493 diff --git a/elements/vm/finalise.d/51-bootloader b/elements/vm/finalise.d/51-bootloader index 54bf04ae..71021ae3 100755 --- a/elements/vm/finalise.d/51-bootloader +++ b/elements/vm/finalise.d/51-bootloader @@ -3,8 +3,8 @@ # Configure grub. Note that the various conditionals here are to handle # different distributions gracefully. -set -e -set -x +set -eux +set -o pipefail # FIXME: [ -n "$IMAGE_BLOCK_DEVICE" ] diff --git a/elements/yum/bin/install-packages b/elements/yum/bin/install-packages index 2ee49cb6..98c0ced0 100755 --- a/elements/yum/bin/install-packages +++ b/elements/yum/bin/install-packages @@ -14,7 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. -set -e +set -eu +set -o pipefail EXTRA_ARGS= ACTION=install diff --git a/elements/yum/pre-install.d/01-yum-keepcache b/elements/yum/pre-install.d/01-yum-keepcache index e5d7b145..121f30f3 100755 --- a/elements/yum/pre-install.d/01-yum-keepcache +++ b/elements/yum/pre-install.d/01-yum-keepcache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail sudo sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf sudo sed -i 's/cachedir=\/var\/cache\/yum/cachedir=\/tmp\/yum/' /etc/yum.conf diff --git a/elements/yum/root.d/50-yum-cache b/elements/yum/root.d/50-yum-cache index a1e43a55..1453db09 100755 --- a/elements/yum/root.d/50-yum-cache +++ b/elements/yum/root.d/50-yum-cache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ] diff --git a/elements/zypper/post-install.d/99-zypper-no-keep-packages b/elements/zypper/post-install.d/99-zypper-no-keep-packages index a68a05e1..675275b6 100755 --- a/elements/zypper/post-install.d/99-zypper-no-keep-packages +++ b/elements/zypper/post-install.d/99-zypper-no-keep-packages @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # Disable caching packages for all repositories sudo zypper modifyrepo --all --no-keep-packages diff --git a/elements/zypper/pre-install.d/01-zypper-keep-packages b/elements/zypper/pre-install.d/01-zypper-keep-packages index 43c01882..7440c185 100755 --- a/elements/zypper/pre-install.d/01-zypper-keep-packages +++ b/elements/zypper/pre-install.d/01-zypper-keep-packages @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail # Enable caching packages for all repositories sudo zypper modifyrepo --all --keep-packages diff --git a/elements/zypper/root.d/50-zypper-cache b/elements/zypper/root.d/50-zypper-cache index 9504bf3a..947499ef 100755 --- a/elements/zypper/root.d/50-zypper-cache +++ b/elements/zypper/root.d/50-zypper-cache @@ -1,6 +1,7 @@ #!/bin/bash -set -e +set -eu +set -o pipefail [ -n "$TARGET_ROOT" ]