Fix ShellCheck warnings
This change fixes all problems reported by ShellCheck [1] which is a nice linting tool for sh/bash scripts. [1] http://www.shellcheck.net/about.html Change-Id: I5ddaa950d4887fb79c4d85935c13f2f1f1ba4797
This commit is contained in:
parent
5c85177037
commit
de3f54be26
|
@ -14,28 +14,28 @@ DISK_SIZE=${2:-""}
|
|||
|
||||
PARTED="$(which parted 2>/dev/null) -s -m"
|
||||
|
||||
if ${PARTED} ${DISK} p | grep -q "unrecognised disk label"; then
|
||||
if ${PARTED} "${DISK}" p | grep -q "unrecognised disk label"; then
|
||||
# We need to create a new label
|
||||
${PARTED} ${DISK} mklabel gpt
|
||||
${PARTED} "${DISK}" mklabel gpt
|
||||
fi
|
||||
|
||||
# We take the free space at the end of the disk.
|
||||
FREESPACE=$(${PARTED} ${DISK} unit B p free | grep "free" | tail -1)
|
||||
FREESPACE=$(${PARTED} "${DISK}" unit B p free | grep "free" | tail -1)
|
||||
if [[ -z "${FREESPACE}" ]]; then
|
||||
echo "Failed to find free space"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BEGIN=$(echo ${FREESPACE} | awk -F: '{print $2}')
|
||||
if [ -z ${DISK_SIZE} ]; then
|
||||
END=$(echo ${FREESPACE} | awk -F: '{print $3}')
|
||||
BEGIN=$(echo "${FREESPACE}" | awk -F: '{print $2}')
|
||||
if [ -z "${DISK_SIZE}" ]; then
|
||||
END=$(echo "${FREESPACE}" | awk -F: '{print $3}')
|
||||
else
|
||||
END="$(( $(echo $BEGIN | rev | cut -c 2- | rev) + $(( ${DISK_SIZE}*1024*1024*1024 )) ))B"
|
||||
END="$(( $(echo "$BEGIN" | rev | cut -c 2- | rev) + $(( DISK_SIZE*1024*1024*1024 )) ))B"
|
||||
fi
|
||||
|
||||
# If you create a partition on a mounted disk, this command returns 1
|
||||
# So we need a different way to catch the error
|
||||
if ${PARTED} ${DISK} unit B mkpart primary ${BEGIN} ${END} | grep -q "^Error"; then
|
||||
if ${PARTED} "${DISK}" unit B mkpart primary "${BEGIN}" "${END}" | grep -q "^Error"; then
|
||||
echo "Failed to create a new primary partition"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -44,8 +44,8 @@ fi
|
|||
# Like when we create a new partition, if you run this command on a mounted
|
||||
# FS the kernel failed to re-read the partition and the command returns 1
|
||||
# event in case of success.
|
||||
PARTID=$(${PARTED} ${DISK} p | tail -1 | awk -F: {'print $1'})
|
||||
if ${PARTED} ${DISK} set ${PARTID} lvm on | grep -q "^Error"; then
|
||||
PARTID=$(${PARTED} "${DISK}" p | tail -1 | awk -F: '{print $1}')
|
||||
if ${PARTED} "${DISK}" set "${PARTID}" lvm on | grep -q "^Error"; then
|
||||
echo "Failed to set the lvm flag on partition ${PARTID}."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
ROOT="$(dirname `readlink -f $0`)"
|
||||
ROOT="$(dirname "$(readlink -f "$0")")"
|
||||
MODULES="${ROOT}"/deployment_scripts/puppet/modules
|
||||
RPM_REPO="${ROOT}"/repositories/centos/
|
||||
DEB_REPO="${ROOT}"/repositories/ubuntu/
|
||||
|
@ -26,8 +26,8 @@ function download {
|
|||
shift
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
FILE=$(basename $1)
|
||||
wget -qO - $1 > $REPO/$FILE
|
||||
FILE=$(basename "$1")
|
||||
wget -qO - "$1" > "$REPO/$FILE"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ download rpm http://mirror.centos.org/centos/6/updates/x86_64/Packages/java-1.8.
|
|||
|
||||
# Install puppet manifests
|
||||
# Clean-up first
|
||||
rm -rf ${MODULES}/{stdlib,concat,lvm,elasticsearch,nginx}
|
||||
mkdir -p ${MODULES}/{elasticsearch,nginx}
|
||||
rm -rf "${MODULES:?}"/{stdlib,concat,lvm,elasticsearch,nginx}
|
||||
mkdir -p "${MODULES}"/{elasticsearch,nginx}
|
||||
|
||||
# Include elasticsearch and nginx manifests from puppetlabs
|
||||
wget -qO- "${ELASTICSEARCH_TARBALL_URL}" | tar -C "${MODULES}/elasticsearch" --strip-components=1 -xz
|
||||
|
@ -62,5 +62,5 @@ wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
|
|||
|
||||
# Untar kibana
|
||||
KIBANA_FOLDER="${MODULES}/lma_logging_analytics/files/kibana/src"
|
||||
mkdir -p ${KIBANA_FOLDER}
|
||||
mkdir -p "${KIBANA_FOLDER}"
|
||||
wget -qO- "${KIBANA_TARBALL_URL}" | tar -C "${KIBANA_FOLDER}" --strip-components=1 -xz
|
||||
|
|
Loading…
Reference in New Issue