Make almost all the element scripts as e/u/pipefail

Following the latest dib-lint reporting, make sure almost all the
scripts are enabling -e, -u, and pipefail.  This eases the discovery of
failing commands, and the usage of unset variables.

There are few exceptions with flags not set:

* elements/hadoop-hdp/install.d/40-install-hdp, set -e
  when installing HDP 2.0, it tries to install tez, which does not seem
  to exist in Hortonworks' repositories

* elements/ssh/install.d/33-ssh, set -e
  the version of augtool (part of augeas 0.10) in older Ubuntu versions
  (like Precise, needed by the cloudera plugin) exits with wrong return
  values in autosave mode

* elements/storm/install.d/60-storm, set -e
  It tries to change the permission of /etc/supervisord.conf, which does
  not seem to exist

Change-Id: Ic1314639dfc6a66c48ca87b6820707a2b0cb1dbd
Partial-Bug: #1435306
This commit is contained in:
Pino Toscano 2015-04-07 10:36:42 +02:00
parent 157dd805e6
commit 2fb2422da8
62 changed files with 112 additions and 8 deletions

View File

@ -3,5 +3,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
rm /etc/apt/apt.conf.d/01proxy

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mkdir -p /etc/apt/apt.conf.d/
touch /etc/apt/apt.conf.d/01proxy

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "$UBUNTU_MIRROR" ]; then
echo "You should specify parameter 'UBUNTU_MIRROR'"

View File

@ -3,5 +3,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mv /opt/repos/* /etc/yum.repos.d/

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mkdir -p /opt/repos
mv /etc/yum.repos.d/* /opt/repos/

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "$CENTOS_MIRROR" ]; then
echo "You should specify parameter 'CENTOS_MIRROR'"

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages which

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages iptables-services

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages iptables-services

View File

@ -3,5 +3,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mv /opt/repos/* /etc/yum.repos.d/

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
mkdir -p /opt/repos
mv /etc/yum.repos.d/* /opt/repos

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "$FEDORA_MIRROR" ]; then
echo "You should specify parameter 'FEDORA_MIRROR'"

View File

@ -7,6 +7,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ "$DISTRO_NAME" != "ubuntu" ]; then
echo "Distro $DISTRO_NAME not supported by CDH. Exiting."

View File

@ -6,6 +6,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
case "$DISTRO_NAME" in
ubuntu )

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [ -z "$JAVA_DOWNLOAD_URL" ]; then
if [ -z "$JAVA_FILE" ]; then

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "ubuntu" ]; then
export DEBIAN_FRONTEND=noninteractive

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
install-packages wget unzip

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
for i in cloudera-scm-agent \
cloudera-scm-server \

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
function add_repo_5_0_0 {
case $DISTRO_NAME in

View File

@ -25,5 +25,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "NOZEROCONF=yes" >> /etc/sysconfig/network

View File

@ -23,6 +23,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget
install-packages ntp

View File

@ -27,6 +27,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -u
set -o pipefail
function install_ganglia {
# Install ganglia

View File

@ -29,5 +29,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
find /etc/yum.repos.d -name "*.repo" -type f | xargs sed "s/enabled=1/enabled=0/" -i

View File

@ -23,6 +23,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# ===== CLEANUP MISC =====
rm -rf /var/cache/*

View File

@ -24,6 +24,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Turn off gmetad
chkconfig gmetad off

View File

@ -24,6 +24,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Turn on ntp service
chkconfig ntpd on

View File

@ -24,6 +24,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Turn off ambari-server service for the first boot of this image
chkconfig ambari-server off

View File

@ -28,6 +28,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# This is only necessary for an HDP 2.x install
if [[ $DIB_HDP_VERSION == "2.0" ]]; then

View File

@ -25,6 +25,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# create a new local yum repository definition that
# includes:

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "START: installing MapR core dependencies"

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "START: installing Scala"

View File

@ -4,5 +4,6 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install -D -g root -o root -m 0644 $(dirname $0)/versions.py /tmp/versions.py

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "START: installing MapR core repository"

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "START: installing MapR ecosystem repository"

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "START: downloading ExtJS library"

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "rhel" ]; then
sed '/^Defaults requiretty*/ s/^/#/' -i /etc/sudoers

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "ubuntu" ]; then
apt-get update

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "MapR version ${DIB_MAPR_VERSION}"

View File

@ -10,6 +10,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
function download_hadoop_package {
echo "Hadoop version $DIB_HADOOP_VERSION will be injected into image. Starting the download"

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [ -z "${JAVA_DOWNLOAD_URL:-}" ]; then
if [ -z "${JAVA_FILE:-}" ]; then

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget tar

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "${HIVE_DOWNLOAD_URL:-}" ]; then
version_check=$(echo $HIVE_VERSION | sed -e '/[0-9]\.[0-9][0-9]\.[0-9]/d')

View File

@ -4,6 +4,7 @@ if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
unset DIB_JAVA_DISTRO
unset JAVA_RC

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "fedora" ]; then
install-packages community-mysql community-mysql-libs community-mysql-server mysql-connector-java

View File

@ -7,6 +7,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ "$DISTRO_NAME" = "ubuntu" ]; then
if [ -e "/etc/init/mysql.conf" ]; then

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
echo "Oozie setup"

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
if [[ "$DIB_HADOOP_VERSION" < "2.0.0" ]]; then
if [ -z "${OOZIE_HADOOP_V1_DOWNLOAD_URL:-}" -a -z "${OOZIE_HADOOP_V1_FILE:-}" ]; then

View File

@ -3,7 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -e
set -eu
set -o pipefail
echo "Begin: installation of Java"

View File

@ -3,5 +3,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages redhat-lsb

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "$DIB_PASSWORD" ]; then
echo "Error during setup password for root"

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "$SAHARA_ELEMENTS_COMMIT_ID" -o -z "$DIB_UTILS_COMMIT_ID" -o -z "$DIB_COMMIT_ID" ]; then
echo "SAHARA_ELEMENTS_COMMIT_ID, DIB_UTILS_COMMIT_ID and DIB_COMMIT_ID must be specified, exiting"

View File

@ -5,6 +5,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget tar

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# We have to chown the Spark directories to make it usable for the default user
# Unfortunately the Ubuntu user does not exists when DIB is creating the image

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "${SPARK_DOWNLOAD_URL:-}" -a -z "${DIB_HADOOP_VERSION:-}" ]; then
echo -e "Neither DIB_HADOOP_VERSION nor SPARK_DOWNLOAD_URL are set. Impossible to install Spark.\nAborting"

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -u
set -o pipefail
echo "Begin: install and configure SSH"
# /etc/ssh/sshd_config is provided by openssh-server

View File

@ -5,6 +5,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -u
set -o pipefail
install-packages wget unzip build-essential uuid-dev git libtool autoconf pkg-config tar

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -z "${STORM_DOWNLOAD_URL:-}" -a -z "${DIB_STORM_VERSION:-}"]; then
echo -e "Neither DIB_STORM_VERSION nor STORM_DOWNLOAD_URL are set. Impossible to install Storm.\nAborting"

View File

@ -3,6 +3,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget

View File

@ -3,5 +3,7 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages -u

View File

@ -5,6 +5,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages wget

View File

@ -7,6 +7,8 @@
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
sed -i -e 's,^exit 0$,[ -f /opt/zookeeper/firstboot.sh ] \&\& sh /opt/zookeeper/firstboot.sh; exit 0,' /etc/rc.local