From 59b31b2e777d25a9ee6f0d1a153c236f5b4b9bfe Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 21 Jun 2014 18:58:16 +0100 Subject: [PATCH] Fix SC2086 - Double quote to prevent globing and word splitting --- bootstrap-salt.sh | 648 +++++++++++++++++++++++----------------------- 1 file changed, 324 insertions(+), 324 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index edd5c59..41d33d2 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -96,7 +96,7 @@ echowarn() { # DESCRIPTION: Echo debug information to stdout. #---------------------------------------------------------------------------------------------------------------------- echodebug() { - if [ $_ECHO_DEBUG -eq $BS_TRUE ]; then + if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then printf "${BC} * DEBUG${EC}: %s\n" "$@"; fi } @@ -113,7 +113,7 @@ check_pip_allowed() { _PIP_ALLOWED_ERROR_MSG="pip based installations were not allowed. Retry using '-P'" fi - if [ $_PIP_ALLOWED -eq $BS_FALSE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_FALSE ]; then echoerror "$_PIP_ALLOWED_ERROR_MSG" usage exit 1 @@ -148,20 +148,20 @@ __check_config_dir() { case "$CC_DIR_NAME" in *.tgz|*.tar.gz) tar -zxf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tgz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.gz") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".tgz") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".tar.gz") CC_DIR_NAME="/tmp/${CC_DIR_BASE}" ;; *.tbz|*.tar.bz2) tar -xjf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tbz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.bz2") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".tbz") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".tar.bz2") CC_DIR_NAME="/tmp/${CC_DIR_BASE}" ;; *.txz|*.tar.xz) tar -xJf "${CC_DIR_NAME}" -C /tmp - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".txz") - CC_DIR_BASE=$(basename ${CC_DIR_BASE} ".tar.xz") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".txz") + CC_DIR_BASE=$(basename "${CC_DIR_BASE}" ".tar.xz") CC_DIR_NAME="/tmp/${CC_DIR_BASE}" ;; esac @@ -344,24 +344,24 @@ __check_unparsed_options() { # Check that we're actually installing one of minion/master/syndic -if [ $_INSTALL_MINION -eq $BS_FALSE ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_INSTALL_MINION" -eq $BS_FALSE ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echowarn "Nothing to install or configure" exit 0 fi -if [ $_CONFIG_ONLY -eq $BS_TRUE ] && [ "$_TEMP_CONFIG_DIR" = "null" ]; then +if [ "$_CONFIG_ONLY" -eq $BS_TRUE ] && [ "$_TEMP_CONFIG_DIR" = "null" ]; then echoerror "In order to run the script in configuration only mode you also need to provide the configuration directory." exit 1 fi # Check that we're installing a minion if we're being passed a master address -if [ $_INSTALL_MINION -eq $BS_FALSE ] && [ $_SALT_MASTER_ADDRESS != "null" ]; then +if [ "$_INSTALL_MINION" -eq $BS_FALSE ] && [ "$_SALT_MASTER_ADDRESS" != "null" ]; then echoerror "Don't pass a master address (-A) if no minion is going to be bootstrapped." exit 1 fi # Check that we're installing a minion if we're being passed a master address -if [ $_INSTALL_MINION -eq $BS_FALSE ] && [ $_SALT_MINION_ID != "null" ]; then +if [ "$_INSTALL_MINION" -eq $BS_FALSE ] && [ "$_SALT_MINION_ID" != "null" ]; then echoerror "Don't pass a minion id (-i) if no minion is going to be bootstrapped." exit 1 fi @@ -383,7 +383,7 @@ if [ "$(echo $ITYPE | egrep '(stable|testing|daily|git)')x" = "x" ]; then fi # If doing a git install, check what branch/tag/sha will be checked out -if [ $ITYPE = "git" ]; then +if [ "$ITYPE" = "git" ]; then if [ "$#" -eq 0 ];then GIT_REV="develop" else @@ -450,7 +450,7 @@ echowarn "Running the unstable version of ${__ScriptName}" __exit_cleanup() { EXIT_CODE=$? - if [ $ITYPE = "git" ] && [ -d /tmp/git/salt ]; then + if [ "$ITYPE" = "git" ] && [ -d /tmp/git/salt ]; then if [ $_KEEP_TEMP_FILES -eq $BS_FALSE ]; then # Clean up the checked out repositry echodebug "Cleaning up the Salt Temporary Git Repository" @@ -463,7 +463,7 @@ __exit_cleanup() { # Remove the logging pipe when the script exits echodebug "Removing the logging pipe $LOGPIPE" - rm -f $LOGPIPE + rm -f "$LOGPIPE" # Kill tee when exiting, CentOS, at least requires this # shellcheck disable=SC2009 @@ -483,7 +483,7 @@ __exit_cleanup() { trap "__trap_errors" INT QUIT ABRT KILL QUIT TERM # Now we're "good" to kill tee - kill -s TERM $TEE_PID + kill -s TERM "$TEE_PID" # In case the 127 errno is not triggered, exit with the "original" exit code exit $EXIT_CODE @@ -497,25 +497,25 @@ LOGPIPE="/tmp/$( echo $__ScriptName | sed s/.sh/.logpipe/g )" # Create our logging pipe # On FreeBSD we have to use mkfifo instead of mknod -mknod $LOGPIPE p >/dev/null 2>&1 || mkfifo $LOGPIPE >/dev/null 2>&1 +mknod "$LOGPIPE" p >/dev/null 2>&1 || mkfifo "$LOGPIPE" >/dev/null 2>&1 if [ $? -ne 0 ]; then echoerror "Failed to create the named pipe required to log" exit 1 fi # What ever is written to the logpipe gets written to the logfile -tee < $LOGPIPE $LOGFILE & +tee < "$LOGPIPE" "$LOGFILE" & # Close STDOUT, reopen it directing it to the logpipe exec 1>&- -exec 1>$LOGPIPE +exec 1>"$LOGPIPE" # Close STDERR, reopen it directing it to the logpipe exec 2>&- -exec 2>$LOGPIPE +exec 2>"$LOGPIPE" # Handle the insecure flags -if [ $_INSECURE_DL -eq $BS_TRUE ]; then +if [ "$_INSECURE_DL" -eq $BS_TRUE ]; then _CURL_ARGS="${_CURL_ARGS} --insecure" _WGET_ARGS="${_WGET_ARGS} --no-check-certificate" _FETCH_ARGS="${_FETCH_ARGS} --no-verify-peer" @@ -549,9 +549,9 @@ __gather_hardware_info() { else CPU_VENDOR_ID=$( sysctl -n hw.model ) fi - CPU_VENDOR_ID_L=$( echo $CPU_VENDOR_ID | tr '[:upper:]' '[:lower:]' ) + CPU_VENDOR_ID_L=$( echo "$CPU_VENDOR_ID" | tr '[:upper:]' '[:lower:]' ) CPU_ARCH=$(uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown") - CPU_ARCH_L=$( echo $CPU_ARCH | tr '[:upper:]' '[:lower:]' ) + CPU_ARCH_L=$( echo "$CPU_ARCH" | tr '[:upper:]' '[:lower:]' ) } __gather_hardware_info @@ -563,9 +563,9 @@ __gather_hardware_info #---------------------------------------------------------------------------------------------------------------------- __gather_os_info() { OS_NAME=$(uname -s 2>/dev/null) - OS_NAME_L=$( echo $OS_NAME | tr '[:upper:]' '[:lower:]' ) + OS_NAME_L=$( echo "$OS_NAME" | tr '[:upper:]' '[:lower:]' ) OS_VERSION=$(uname -r) - OS_VERSION_L=$( echo $OS_VERSION | tr '[:upper:]' '[:lower:]' ) + OS_VERSION_L=$( echo "$OS_VERSION" | tr '[:upper:]' '[:lower:]' ) } __gather_os_info @@ -626,7 +626,7 @@ __sort_release_files() { secondary_release_files="" # Sort know VS un-known files first for release_file in $(echo "${@}" | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do - match=$(echo $release_file | egrep -i ${KNOWN_RELEASE_FILES}) + match=$(echo "$release_file" | egrep -i "${KNOWN_RELEASE_FILES}") if [ "x${match}" != "x" ]; then primary_release_files="${primary_release_files} ${release_file}" else @@ -638,14 +638,14 @@ __sort_release_files() { max_prio="redhat-release centos-release" for entry in $max_prio; do if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then - primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g") + primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g") fi done # Now, least important goes last in the min_prio list min_prio="lsb-release" for entry in $min_prio; do if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then - primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g") + primary_release_files=$(echo "${primary_release_files}" | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g") fi done @@ -707,11 +707,11 @@ __gather_linux_system_info() { [ -L "/etc/${rsource}" ] && continue # Don't follow symlinks [ ! -f "/etc/${rsource}" ] && continue # Does not exist - n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//') - rv=$( (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' ) + n=$(echo "${rsource}" | sed -e 's/[_-]release$//' -e 's/[_-]version$//') + rv=$( (grep VERSION "/etc/${rsource}"; cat "/etc/${rsource}") | grep '[0-9]' | sed -e 'q' ) [ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource v=$(__parse_version_string "$rv") - case $(echo ${n} | tr '[:upper:]' '[:lower:]') in + case $(echo "${n}" | tr '[:upper:]' '[:lower:]') in redhat ) if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then n="CentOS" @@ -743,13 +743,13 @@ __gather_linux_system_info() { n="Amazon Linux AMI" break esac - done < /etc/${rsource} + done < "/etc/${rsource}" ;; os ) nn="$(__unquote_string $(grep '^ID=' /etc/os-release | sed -e 's/^ID=\(.*\)$/\1/g'))" rv="$(__unquote_string $(grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g'))" [ "${rv}x" != "x" ] && v=$(__parse_version_string "$rv") || v="" - case $(echo ${nn} | tr '[:upper:]' '[:lower:]') in + case $(echo "${nn}" | tr '[:upper:]' '[:lower:]') in arch ) n="Arch Linux" v="" # Arch Linux does not provide a version. @@ -912,7 +912,7 @@ __ubuntu_derivatives_translation() { elementary_os_02_ubuntu_base="12.04" # Translate Ubuntu derivatives to their base Ubuntu version - match=$(echo $DISTRO_NAME_L | egrep ${UBUNTU_DERIVATIVES}) + match=$(echo "$DISTRO_NAME_L" | egrep ${UBUNTU_DERIVATIVES}) if [ "x${match}" != "x" ]; then case $match in @@ -990,31 +990,31 @@ if [ "x${_HTTP_PROXY}" != "x" ]; then fi # Let users know what's going to be installed/configured -if [ $_INSTALL_MINION -eq $BS_TRUE ]; then - if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Installing minion" else echoinfo "Configuring minion" fi fi -if [ $_INSTALL_MASTER -eq $BS_TRUE ]; then - if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Installing master" else echoinfo "Configuring master" fi fi -if [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then - if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Installing syndic" else echoinfo "Configuring syndic" fi fi -if [ $_INSTALL_CLOUD -eq $BS_TRUE ] && [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Installing Apache-Libcloud required for salt-cloud" fi @@ -1023,7 +1023,7 @@ if [ $_START_DAEMONS -eq $BS_FALSE ]; then fi # Simplify distro name naming on functions -DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g') +DISTRO_NAME_L=$(echo "$DISTRO_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g') # For Ubuntu derivatives, pretend to be their Ubuntu base version __ubuntu_derivatives_translation @@ -1038,8 +1038,8 @@ if [ "x${DISTRO_VERSION}" = "x" ] || [ $__SIMPLIFY_VERSION -eq $BS_FALSE ]; then PREFIXED_DISTRO_MAJOR_VERSION="" PREFIXED_DISTRO_MINOR_VERSION="" else - DISTRO_MAJOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')" - DISTRO_MINOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).\([0-9]*\).*/\2/g')" + DISTRO_MAJOR_VERSION=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g') + DISTRO_MINOR_VERSION=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).\([0-9]*\).*/\2/g') PREFIXED_DISTRO_MAJOR_VERSION="_${DISTRO_MAJOR_VERSION}" if [ "${PREFIXED_DISTRO_MAJOR_VERSION}" = "_" ]; then PREFIXED_DISTRO_MAJOR_VERSION="" @@ -1051,13 +1051,13 @@ else fi # Only Ubuntu has daily packages, let's let users know about that -if ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ $ITYPE = "daily" ]); then +if ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$ITYPE" = "daily" ]); then echoerror "${DISTRO_NAME} does not have daily packages support" exit 1 fi # Only RedHat based distros have testing support -if [ ${ITYPE} = "testing" ]; then +if [ "${ITYPE}" = "testing" ]; then if [ "$(echo ${DISTRO_NAME_L} | egrep '(centos|red_hat|amazon|oracle)')x" = "x" ]; then echoerror "${DISTRO_NAME} does not have testing packages support" exit 1 @@ -1101,32 +1101,32 @@ __git_clone_and_checkout() { if [ "x$(git remote -v | grep $_SALTSTACK_REPO_URL)" != "x" ]; then git fetch --tags upstream else - git remote add upstream $_SALTSTACK_REPO_URL + git remote add upstream "$_SALTSTACK_REPO_URL" git fetch --tags upstream fi - git reset --hard $GIT_REV || return 1 + git reset --hard "$GIT_REV" || return 1 # Just calling `git reset --hard $GIT_REV` on a branch name that has # already been checked out will not update that branch to the upstream # HEAD; instead it will simply reset to itself. Check the ref to see # if it is a branch name, check out the branch, and pull in the # changes. - git branch -a | grep -q ${GIT_REV} + git branch -a | grep -q "${GIT_REV}" if [ $? -eq 0 ]; then git pull --rebase || return 1 fi else - git clone $_SALT_REPO_URL || return 1 - cd $SALT_GIT_CHECKOUT_DIR + git clone "$_SALT_REPO_URL" || return 1 + cd "$SALT_GIT_CHECKOUT_DIR" - if [ $_SALT_REPO_URL != $_SALTSTACK_REPO_URL ]; then + if [ "$_SALT_REPO_URL" != "$_SALTSTACK_REPO_URL" ]; then # We need to add the saltstack repository as a remote and fetch tags for proper versioning - git remote add upstream $_SALTSTACK_REPO_URL + git remote add upstream "$_SALTSTACK_REPO_URL" git fetch --tags upstream fi - git checkout $GIT_REV || return 1 + git checkout "$GIT_REV" || return 1 fi return 0 @@ -1160,7 +1160,7 @@ __check_end_of_life_versions() { case "${DISTRO_NAME_L}" in debian) # Debian versions bellow 6 are not supported - if [ $DISTRO_MAJOR_VERSION -lt 6 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " https://wiki.debian.org/DebianReleases" @@ -1175,10 +1175,10 @@ __check_end_of_life_versions() { # = 10.10 # = 11.04 # = 11.10 - if ([ $DISTRO_MAJOR_VERSION -eq 10 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]) || \ - ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -eq 04 ]) || \ - ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]) || \ - [ $DISTRO_MAJOR_VERSION -lt 10 ]; then + if ([ "$DISTRO_MAJOR_VERSION" -eq 10 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]) || \ + ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -eq 04 ]) || \ + ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]) || \ + [ "$DISTRO_MAJOR_VERSION" -lt 10 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " https://wiki.ubuntu.com/Releases" @@ -1190,7 +1190,7 @@ __check_end_of_life_versions() { # openSUSE versions not supported # # <= 12.1 - if ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -eq 1 ]) || [ $DISTRO_MAJOR_VERSION -lt 12 ]; then + if ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -eq 1 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 12 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " http://en.opensuse.org/Lifetime" @@ -1206,7 +1206,7 @@ __check_end_of_life_versions() { if [ "x${SUSE_PATCHLEVEL}" = "x" ]; then SUSE_PATCHLEVEL="00" fi - if ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $SUSE_PATCHLEVEL -lt 02 ]) || [ $DISTRO_MAJOR_VERSION -lt 11 ]; then + if ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$SUSE_PATCHLEVEL" -lt 02 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 11 ]; then echoerror "Versions lower than SuSE 11 SP2 are not supported." echoerror "Please consider upgrading to the next stable" exit 1 @@ -1215,7 +1215,7 @@ __check_end_of_life_versions() { fedora) # Fedora lower than 18 are no longer supported - if [ $DISTRO_MAJOR_VERSION -lt 18 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 18 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " https://fedoraproject.org/wiki/Releases" @@ -1225,7 +1225,7 @@ __check_end_of_life_versions() { centos) # CentOS versions lower than 5 are no longer supported - if [ $DISTRO_MAJOR_VERSION -lt 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " http://wiki.centos.org/Download" @@ -1235,7 +1235,7 @@ __check_end_of_life_versions() { red_hat*linux) # Red Hat (Enterprise) Linux versions lower than 5 are no longer supported - if [ $DISTRO_MAJOR_VERSION -lt 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " https://access.redhat.com/support/policy/updates/errata/" @@ -1245,7 +1245,7 @@ __check_end_of_life_versions() { freebsd) # FreeBSD versions lower than 9.1 are not supported. - if ([ $DISTRO_MAJOR_VERSION -eq 9 ] && [ $DISTRO_MINOR_VERSION -lt 01 ]) || [ $DISTRO_MAJOR_VERSION -lt 9 ]; then + if ([ "$DISTRO_MAJOR_VERSION" -eq 9 ] && [ "$DISTRO_MINOR_VERSION" -lt 01 ]) || [ "$DISTRO_MAJOR_VERSION" -lt 9 ]; then echoerror "Versions lower than FreeBSD 9.1 are not supported." exit 1 fi @@ -1296,11 +1296,11 @@ copyfile() { # The destination file does not exist, copy echodebug "Copying $sfile to $dfile" cp "$sfile" "$dfile" || return 1 - elif [ -f "$dfile" ] && [ $overwrite -eq $BS_TRUE ]; then + elif [ -f "$dfile" ] && [ "$overwrite" -eq $BS_TRUE ]; then # The destination exist and we're overwriting echodebug "Overriding $dfile with $sfile" cp -f "$sfile" "$dfile" || return 1 - elif [ -f "$dfile" ] && [ $overwrite -ne $BS_TRUE ]; then + elif [ -f "$dfile" ] && [ "$overwrite" -ne $BS_TRUE ]; then echodebug "Not overriding $dfile with $sfile" fi return 0 @@ -1330,7 +1330,7 @@ movefile() { # We're being told not to move files, instead copy them so we can keep # them around echodebug "Since BS_KEEP_TEMP_FILES=1 we're copying files instead of moving them" - copyfile "$sfile" "$dfile" $overwrite + copyfile "$sfile" "$dfile" "$overwrite" return $? fi @@ -1352,11 +1352,11 @@ movefile() { # The destination file does not exist, copy echodebug "Moving $sfile to $dfile" mv "$sfile" "$dfile" || return 1 - elif [ -f "$dfile" ] && [ $overwrite -eq $BS_TRUE ]; then + elif [ -f "$dfile" ] && [ "$overwrite" -eq $BS_TRUE ]; then # The destination exist and we're overwriting echodebug "Overriding $dfile with $sfile" mv -f "$sfile" "$dfile" || return 1 - elif [ -f "$dfile" ] && [ $overwrite -ne $BS_TRUE ]; then + elif [ -f "$dfile" ] && [ "$overwrite" -ne $BS_TRUE ]; then echodebug "Not overriding $dfile with $sfile" fi @@ -1408,7 +1408,7 @@ __check_services_upstart() { echodebug "Checking if service ${servicename} is enabled" # Check if service is enabled to start at boot - initctl list | grep ${servicename} > /dev/null 2>&1 + initctl list | grep "${servicename}" > /dev/null 2>&1 if [ $? -eq 0 ]; then echodebug "Service ${servicename} is enabled" @@ -1563,9 +1563,9 @@ __enable_universe_repository() { echodebug "Enabling the universe repository" # Ubuntu versions higher than 12.04 do not live in the old repositories - if [ $DISTRO_MAJOR_VERSION -gt 12 ] || ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -gt 04 ]); then + if [ "$DISTRO_MAJOR_VERSION" -gt 12 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -gt 04 ]); then add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe" || return 1 - elif [ $DISTRO_MAJOR_VERSION -lt 11 ] && [ $DISTRO_MINOR_VERSION -lt 10 ]; then + elif [ "$DISTRO_MAJOR_VERSION" -lt 11 ] && [ "$DISTRO_MINOR_VERSION" -lt 10 ]; then # Below Ubuntu 11.10, the -y flag to add-apt-repository is not supported add-apt-repository "deb http://old-releases.ubuntu.com/ubuntu $(lsb_release -sc) universe" || return 1 fi @@ -1585,7 +1585,7 @@ install_ubuntu_deps() { # Install Keys __apt_get_install_noinput debian-archive-keyring && apt-get update - if [ $DISTRO_MAJOR_VERSION -gt 12 ] || ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]); then + if [ "$DISTRO_MAJOR_VERSION" -gt 12 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]); then # Above Ubuntu 12.04 add-apt-repository is in a different package __apt_get_install_noinput software-properties-common || return 1 else @@ -1594,7 +1594,7 @@ install_ubuntu_deps() { __enable_universe_repository || return 1 - if [ $DISTRO_MAJOR_VERSION -gt 11 ] || ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -gt 04 ]); then + if [ "$DISTRO_MAJOR_VERSION" -gt 11 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -gt 04 ]); then # Above Ubuntu 11.04 add a -y flag add-apt-repository -y ppa:saltstack/salt || return 1 else @@ -1606,7 +1606,7 @@ install_ubuntu_deps() { # Minimal systems might not have upstart installed, install it __apt_get_install_noinput upstart - if [ $DISTRO_MAJOR_VERSION -gt 12 ] || ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -gt 03 ]); then + if [ "$DISTRO_MAJOR_VERSION" -gt 12 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -gt 03 ]); then __apt_get_install_noinput python-requests __PIP_PACKAGES="" else @@ -1619,7 +1619,7 @@ install_ubuntu_deps() { # Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813 __apt_get_install_noinput procps pciutils - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install 'apache-libcloud'" if [ "x${__PIP_PACKAGES}" = "x" ]; then __apt_get_install_noinput python-pip @@ -1631,7 +1631,7 @@ install_ubuntu_deps() { pip install -U ${__PIP_PACKAGES} fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -1645,7 +1645,7 @@ install_ubuntu_deps() { install_ubuntu_daily_deps() { install_ubuntu_deps - if [ $DISTRO_MAJOR_VERSION -eq 12 ] || [ $DISTRO_MAJOR_VERSION -gt 12 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 12 ] || [ "$DISTRO_MAJOR_VERSION" -gt 12 ]; then # Above Ubuntu 11.10 add-apt-repository is in a different package __apt_get_install_noinput software-properties-common || return 1 else @@ -1655,7 +1655,7 @@ install_ubuntu_daily_deps() { __enable_universe_repository || return 1 # for anything up to and including 11.04 do not use the -y option - if [ $DISTRO_MAJOR_VERSION -gt 11 ] || ([ $DISTRO_MAJOR_VERSION -eq 11 ] && [ $DISTRO_MINOR_VERSION -gt 04 ]); then + if [ "$DISTRO_MAJOR_VERSION" -gt 11 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 11 ] && [ "$DISTRO_MINOR_VERSION" -gt 04 ]); then # Above Ubuntu 11.04 add a -y flag add-apt-repository -y ppa:saltstack/salt-daily || return 1 else @@ -1664,7 +1664,7 @@ install_ubuntu_daily_deps() { apt-get update - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -1689,13 +1689,13 @@ install_ubuntu_git_deps() { install_ubuntu_stable() { packages="" - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then packages="${packages} salt-minion" fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then packages="${packages} salt-master" fi - if [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then packages="${packages} salt-syndic" fi __apt_get_install_noinput ${packages} || return 1 @@ -1709,7 +1709,7 @@ install_ubuntu_daily() { install_ubuntu_git() { if [ -f ${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py ]; then - python setup.py install --install-layout=deb --salt-config-dir=$_SALT_ETC_DIR || return 1 + python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || return 1 else python setup.py install --install-layout=deb || return 1 fi @@ -1720,9 +1720,9 @@ install_ubuntu_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ]; then _upstart_conf="/etc/init/salt-$fname.conf" @@ -1755,9 +1755,9 @@ install_ubuntu_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ]; then echodebug "There's upstart support while checking salt-$fname" @@ -1787,9 +1787,9 @@ install_ubuntu_restart_daemons() { install_ubuntu_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then __check_services_upstart salt-$fname || return 1 elif [ -f /etc/init.d/salt-$fname ]; then @@ -1827,12 +1827,12 @@ install_debian_deps() { __PIP_PACKAGES="requests" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then __PIP_PACKAGES="${__PIP_PACKAGES} 'apache-libcloud>=$_LIBCLOUD_MIN_VERSION'" fi pip install -U ${__PIP_PACKAGES} - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -1858,7 +1858,7 @@ install_debian_6_deps() { wget $_WGET_ARGS -q http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key -O - | apt-key add - || return 1 - if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then echowarn "PyZMQ will be installed from PyPI in order to compile it against ZMQ3" echowarn "This is required for long term stable minion connections to the master." echowarn "YOU WILL END UP WITH QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE" @@ -1917,13 +1917,13 @@ _eof # Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813 __apt_get_install_noinput python-requests python-pip procps pciutils - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" __apt_get_install_noinput python-pip pip install -U "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -1956,7 +1956,7 @@ install_debian_7_deps() { wget $_WGET_ARGS -q http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key -O - | apt-key add - || return 1 - if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then echowarn "PyZMQ will be installed from PyPI in order to compile it against ZMQ3" echowarn "This is required for long term stable minion connections to the master." echowarn "YOU WILL END UP WITH QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE" @@ -1995,12 +1995,12 @@ _eof fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" pip install -U "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -2041,12 +2041,12 @@ install_debian_git_deps() { CONFIG_SALT_FUNC="config_salt" fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" pip install -U "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -2060,7 +2060,7 @@ install_debian_git_deps() { install_debian_6_git_deps() { install_debian_6_deps || return 1 - if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then easy_install -U Jinja2 || return 1 __apt_get_install_noinput lsb-release python python-pkg-resources python-crypto \ python-m2crypto python-yaml msgpack-python python-pip git || return 1 @@ -2076,7 +2076,7 @@ install_debian_6_git_deps() { install_debian_git_deps || return 1 # Grab the actual deps fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then __apt_get_upgrade_noinput || return 1 fi @@ -2096,18 +2096,18 @@ install_debian_8_git_deps() { __install_debian_stable() { packages="" - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then packages="${packages} salt-minion" fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then packages="${packages} salt-master" fi - if [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then packages="${packages} salt-syndic" fi __apt_get_install_noinput ${packages} || return 1 - if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then # Building pyzmq from source to build it against libzmq3. # Should override current installation # Using easy_install instead of pip because at least on Debian 6, @@ -2135,7 +2135,7 @@ install_debian_8_stable() { } install_debian_git() { - if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then + if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then # Building pyzmq from source to build it against libzmq3. # Should override current installation # Using easy_install instead of pip because at least on Debian 6, @@ -2144,7 +2144,7 @@ install_debian_git() { fi if [ -f ${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py ]; then - python setup.py install --install-layout=deb --salt-config-dir=$_SALT_ETC_DIR || return 1 + python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || return 1 else python setup.py install --install-layout=deb || return 1 fi @@ -2169,27 +2169,27 @@ install_debian_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - if [ -f ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init ]; then - copyfile ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init /etc/init.d/salt-$fname + if [ -f "${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" ]; then + copyfile "${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" "/etc/init.d/salt-$fname" fi - chmod +x /etc/init.d/salt-$fname - update-rc.d salt-$fname defaults + chmod +x "/etc/init.d/salt-$fname" + update-rc.d "salt-$fname" defaults done } install_debian_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq $BS_FALSE ] && return for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue /etc/init.d/salt-$fname stop > /dev/null 2>&1 /etc/init.d/salt-$fname start @@ -2199,9 +2199,9 @@ install_debian_restart_daemons() { install_debian_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_debian salt-$fname || return 1 done return 0 @@ -2218,13 +2218,13 @@ install_debian_check_services() { install_fedora_deps() { packages="yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq python-requests" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then packages="${packages} python-libcloud" fi yum install -y ${packages} || return 1 - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then yum -y update || return 1 fi @@ -2238,10 +2238,10 @@ install_fedora_deps() { install_fedora_stable() { packages="" - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then packages="${packages} salt-minion" fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ] || [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then packages="${packages} salt-master" fi yum install -y ${packages} || return 1 @@ -2251,9 +2251,9 @@ install_fedora_stable() { install_fedora_stable_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) sleep 0.1 @@ -2278,8 +2278,8 @@ install_fedora_git_deps() { } install_fedora_git() { - if [ -f ${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py ]; then - python setup.py install --salt-config-dir=$_SALT_ETC_DIR || return 1 + if [ -f "${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then + python setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1 else python setup.py install || return 1 fi @@ -2290,9 +2290,9 @@ install_fedora_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue copyfile ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname.service /lib/systemd/system/salt-$fname.service @@ -2308,9 +2308,9 @@ install_fedora_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue systemctl stop salt-$fname > /dev/null 2>&1 systemctl start salt-$fname.service @@ -2320,9 +2320,9 @@ install_fedora_restart_daemons() { install_fedora_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_systemd salt-$fname || return 1 done return 0 @@ -2340,17 +2340,17 @@ __install_epel_repository() { if [ ${__EPEL_REPOS_INSTALLED} -eq $BS_TRUE ]; then return 0 fi - if [ $CPU_ARCH_L = "i686" ]; then + if [ "$CPU_ARCH_L" = "i686" ]; then EPEL_ARCH="i386" else EPEL_ARCH=$CPU_ARCH_L fi - if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then - rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/5/${EPEL_ARCH}/epel-release-5-4.noarch.rpm || return 1 - elif [ $DISTRO_MAJOR_VERSION -eq 6 ]; then - rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm || return 1 - elif [ $DISTRO_MAJOR_VERSION -eq 7 ]; then - rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/beta/7/${EPEL_ARCH}/epel-release-7-0.1.noarch.rpm || return 1 + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then + rpm -Uvh --force "http://mirrors.kernel.org/fedora-epel/5/${EPEL_ARCH}/epel-release-5-4.noarch.rpm" || return 1 + elif [ "$DISTRO_MAJOR_VERSION" -eq 6 ]; then + rpm -Uvh --force "http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm" || return 1 + elif [ "$DISTRO_MAJOR_VERSION" -eq 7 ]; then + rpm -Uvh --force "http://mirrors.kernel.org/fedora-epel/beta/7/${EPEL_ARCH}/epel-release-7-0.1.noarch.rpm" || return 1 else echoerror "Failed add EPEL repository support." return 1 @@ -2362,28 +2362,28 @@ __install_epel_repository() { install_centos_stable_deps() { __install_epel_repository - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then yum -y update || return 1 fi packages="yum-utils chkconfig" - if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then packages="${packages} python26-PyYAML python26-m2crypto m2crypto python26 python26-requests" packages="${packages} python26-crypto python26-msgpack python26-zmq python26-jinja2" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" packages="${packages} python26-setuptools" fi else packages="${packages} PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2 python-requests" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" packages="${packages} python-pip" fi fi - if [ $DISTRO_NAME_L = "oracle_linux" ]; then + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! for package in ${packages}; do yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 @@ -2392,9 +2392,9 @@ install_centos_stable_deps() { yum -y install ${packages} --enablerepo=${_EPEL_REPO} || return 1 fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then easy_install-2.6 "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" else pip-python install "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" @@ -2403,7 +2403,7 @@ install_centos_stable_deps() { if [ "x${_EXTRA_PACKAGES}" != "x" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" - if [ $DISTRO_NAME_L = "oracle_linux" ]; then + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! for package in ${_EXTRA_PACKAGES}; do yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 @@ -2418,13 +2418,13 @@ install_centos_stable_deps() { install_centos_stable() { packages="" - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then packages="${packages} salt-minion" fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ] || [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then packages="${packages} salt-master" fi - if [ $DISTRO_NAME_L = "oracle_linux" ]; then + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! for package in ${packages}; do yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 @@ -2438,9 +2438,9 @@ install_centos_stable() { install_centos_stable_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /etc/init.d/salt-$fname ]; then # Still in SysV init!? @@ -2451,7 +2451,7 @@ install_centos_stable_post() { install_centos_git_deps() { install_centos_stable_deps || return 1 - if [ $DISTRO_NAME_L = "oracle_linux" ]; then + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then # try both ways --enablerepo=X disables ALL OTHER REPOS!!!! yum -y install git || yum -y install git --enablerepo=${_EPEL_REPO} || return 1 else @@ -2470,13 +2470,13 @@ install_centos_git_deps() { } install_centos_git() { - if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then _PYEXE=python2.6 else _PYEXE=python2 fi if [ -f ${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py ]; then - $_PYEXE setup.py install --salt-config-dir=$_SALT_ETC_DIR || return 1 + $_PYEXE setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1 else $_PYEXE setup.py install || return 1 fi @@ -2487,9 +2487,9 @@ install_centos_git_post() { for fname in master minion syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # While the RPM's use init.d, so will we. if [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then @@ -2519,9 +2519,9 @@ install_centos_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then # We have upstart support and upstart knows about our service @@ -2566,9 +2566,9 @@ install_centos_testing_post() { install_centos_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then __check_services_upstart salt-$fname || return 1 elif [ -f /etc/init.d/salt-$fname ]; then @@ -2590,7 +2590,7 @@ install_centos_check_services() { install_red_hat_linux_stable_deps() { __install_epel_repository - if [ $DISTRO_MAJOR_VERSION -eq 6 ] || [ $DISTRO_MAJOR_VERSION -gt 6 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 6 ] || [ "$DISTRO_MAJOR_VERSION" -gt 6 ]; then # Let's enable package installation testing, kind of, --dry-run echoinfo "Installing 'yum-tsflags' to test for package installation success" @@ -2949,27 +2949,27 @@ install_scientific_linux_check_services() { install_amazon_linux_ami_deps() { # According to http://aws.amazon.com/amazon-linux-ami/faqs/#epel we should # enable the EPEL 6 repo - if [ $CPU_ARCH_L = "i686" ]; then + if [ "$CPU_ARCH_L" = "i686" ]; then EPEL_ARCH="i386" else EPEL_ARCH=$CPU_ARCH_L fi rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm || return 1 - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then yum -y update || return 1 fi packages="PyYAML m2crypto python-crypto python-msgpack python-zmq python-ordereddict python-jinja2 python-requests" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" packages="${packages} python-pip" fi yum -y install ${packages} --enablerepo=${_EPEL_REPO} || return 1 - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" pip-python install "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" fi @@ -3042,11 +3042,11 @@ install_amazon_linux_ami_testing_post() { # install_arch_linux_stable_deps() { - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then pacman -Syyu --noconfirm --needed || return 1 fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then pacman -Sy --noconfirm --needed apache-libcloud || return 1 fi @@ -3092,7 +3092,7 @@ install_arch_linux_stable() { install_arch_linux_git() { if [ -f ${SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py ]; then - python2 setup.py install --salt-config-dir=$_SALT_ETC_DIR || return 1 + python2 setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1 else python2 setup.py install || return 1 fi @@ -3104,16 +3104,16 @@ install_arch_linux_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # Since Arch's pacman renames configuration files - if [ "$_TEMP_CONFIG_DIR" != "null" ] && [ -f $_SALT_ETC_DIR/$fname.pacorig ]; then + if [ "$_TEMP_CONFIG_DIR" != "null" ] && [ -f "$_SALT_ETC_DIR/$fname.pacorig" ]; then # Since a configuration directory was provided, it also means that any # configuration file copied was renamed by Arch, see: # https://wiki.archlinux.org/index.php/Pacnew_and_Pacsave_Files#.pacorig - copyfile $_SALT_ETC_DIR/$fname.pacorig $_SALT_ETC_DIR/$fname $BS_TRUE + copyfile "$_SALT_ETC_DIR/$fname.pacorig" "$_SALT_ETC_DIR/$fname" $BS_TRUE fi if [ -f /usr/bin/systemctl ]; then @@ -3135,9 +3135,9 @@ install_arch_linux_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /usr/bin/systemctl ]; then copyfile ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname.service /lib/systemd/system/salt-$fname.service @@ -3163,9 +3163,9 @@ install_arch_linux_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /usr/bin/systemctl ]; then /usr/bin/systemctl stop salt-$fname.service > /dev/null 2>&1 @@ -3185,9 +3185,9 @@ install_arch_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_systemd salt-$fname || return 1 done return 0 @@ -3202,13 +3202,13 @@ install_arch_check_services() { # FreeBSD Install Functions # __freebsd_get_packagesite() { - if [ $CPU_ARCH_L = "amd64" ]; then + if [ "$CPU_ARCH_L" = "amd64" ]; then BSD_ARCH="x86:64" - elif [ $CPU_ARCH_L = "x86_64" ]; then + elif [ "$CPU_ARCH_L" = "x86_64" ]; then BSD_ARCH="x86:64" - elif [ $CPU_ARCH_L = "i386" ]; then + elif [ "$CPU_ARCH_L" = "i386" ]; then BSD_ARCH="x86:32" - elif [ $CPU_ARCH_L = "i686" ]; then + elif [ "$CPU_ARCH_L" = "i686" ]; then BSD_ARCH="x86:32" fi @@ -3360,7 +3360,7 @@ install_freebsd_git() { else /usr/local/bin/python setup.py install \ --salt-root-dir=/usr/local \ - --salt-config-dir=${_SALT_ETC_DIR} \ + --salt-config-dir="${_SALT_ETC_DIR}" \ --salt-cache-dir=/var/cache/salt \ --salt-sock-dir=/var/run/salt \ --salt-srv-root-dir=/srv \ @@ -3386,9 +3386,9 @@ install_freebsd_9_stable_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue enable_string="salt_${fname}_enable=\"YES\"" grep "$enable_string" /etc/rc.conf >/dev/null 2>&1 @@ -3419,9 +3419,9 @@ install_freebsd_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue service salt_$fname stop > /dev/null 2>&1 service salt_$fname start @@ -3447,12 +3447,12 @@ install_smartos_deps() { CONFIG_SALT_FUNC="config_salt" # Let's download, since they were not provided, the default configuration files - if [ ! -f $_SALT_ETC_DIR/minion ] && [ ! -f $_TEMP_CONFIG_DIR/minion ]; then - curl $_CURL_ARGS -s -o $_TEMP_CONFIG_DIR/minion -L \ + if [ ! -f "$_SALT_ETC_DIR/minion" ] && [ ! -f "$_TEMP_CONFIG_DIR/minion" ]; then + curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/minion" -L \ https://raw.githubusercontent.com/saltstack/salt/develop/conf/minion || return 1 fi if [ ! -f $_SALT_ETC_DIR/master ] && [ ! -f $_TEMP_CONFIG_DIR/master ]; then - curl $_CURL_ARGS -s -o $_TEMP_CONFIG_DIR/master -L \ + curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/master" -L \ https://raw.githubusercontent.com/saltstack/salt/develop/conf/master || return 1 fi fi @@ -3497,15 +3497,15 @@ install_smartos_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue svcs network/salt-$fname > /dev/null 2>&1 if [ $? -eq 1 ]; then - if [ ! -f $_TEMP_CONFIG_DIR/salt-$fname.xml ]; then - curl $_CURL_ARGS -s -o $_TEMP_CONFIG_DIR/salt-$fname.xml -L \ - https://raw.githubusercontent.com/saltstack/salt/develop/pkg/smartos/salt-$fname.xml + if [ ! -f "$_TEMP_CONFIG_DIR/salt-$fname.xml" ]; then + curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/salt-$fname.xml" -L \ + "https://raw.githubusercontent.com/saltstack/salt/develop/pkg/smartos/salt-$fname.xml" fi svccfg import $_TEMP_CONFIG_DIR/salt-$fname.xml if [ "${VIRTUAL_TYPE}" = "global" ]; then @@ -3526,13 +3526,13 @@ install_smartos_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - svcs network/salt-$fname > /dev/null 2>&1 + svcs "network/salt-$fname" > /dev/null 2>&1 if [ $? -eq 1 ]; then - svccfg import ${SALT_GIT_CHECKOUT_DIR}/pkg/smartos/salt-$fname.xml + svccfg import "${SALT_GIT_CHECKOUT_DIR}/pkg/smartos/salt-$fname.xml" if [ "${VIRTUAL_TYPE}" = "global" ]; then if [ ! -d $smf_dir ]; then mkdir -p "$smf_dir" @@ -3551,9 +3551,9 @@ install_smartos_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # Stop if running && Start service svcadm disable salt-$fname > /dev/null 2>&1 @@ -3577,7 +3577,7 @@ install_opensuse_stable_deps() { if [ $? -eq 1 ]; then # zypper does not yet know nothing about devel_languages_python zypper --non-interactive addrepo --refresh \ - http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo || return 1 + "http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo" || return 1 fi zypper --gpg-auto-import-keys --non-interactive refresh @@ -3588,19 +3588,19 @@ install_opensuse_stable_deps() { return 1 fi - if [ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -eq 3 ]; then + if [ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -eq 3 ]; then # Because patterns-openSUSE-minimal_base-conflicts conflicts with python, lets remove the first one zypper --non-interactive remove patterns-openSUSE-minimal_base-conflicts fi - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then zypper --gpg-auto-import-keys --non-interactive update || return 1 fi packages="libzmq3 python python-Jinja2 python-M2Crypto python-PyYAML python-requests" packages="${packages} python-msgpack-python python-pycrypto python-pyzmq python-xml" - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then packages="${packages} python-apache-libcloud" fi @@ -3631,13 +3631,13 @@ install_opensuse_git_deps() { install_opensuse_stable() { packages="" - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then packages="${packages} salt-minion" fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then packages="${packages} salt-master" fi - if [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then packages="${packages} salt-syndic" fi zypper --non-interactive install --auto-agree-with-licenses $packages || return 1 @@ -3653,9 +3653,9 @@ install_opensuse_stable_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) @@ -3674,9 +3674,9 @@ install_opensuse_git_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then copyfile ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.service /lib/systemd/system/salt-$fname.service @@ -3697,9 +3697,9 @@ install_opensuse_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then systemctl stop salt-$fname > /dev/null 2>&1 @@ -3721,9 +3721,9 @@ install_opensuse_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_systemd salt-$fname || return 1 done return 0 @@ -3750,38 +3750,38 @@ install_suse_11_stable_deps() { if [ $? -eq 1 ]; then # zypper does not yet know nothing about devel_languages_python zypper --non-interactive addrepo --refresh \ - http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo || return 1 + "http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo" || return 1 fi zypper --gpg-auto-import-keys --non-interactive refresh || return 1 - if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then zypper --gpg-auto-import-keys --non-interactive update || return 1 fi packages="libzmq3 python python-Jinja2 'python-M2Crypto>=0.21' python-msgpack-python" packages="${packages} python-pycrypto python-pyzmq python-pip python-xml python-requests" - if [ $SUSE_PATCHLEVEL -eq 1 ]; then + if [ "$SUSE_PATCHLEVEL" -eq 1 ]; then check_pip_allowed echowarn "PyYaml will be installed using pip" else packages="${packages} python-PyYAML" fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then packages="${packages} python-apache-libcloud" fi zypper --non-interactive install --auto-agree-with-licenses ${packages} || return 1 - if [ $SUSE_PATCHLEVEL -eq 1 ]; then + if [ "$SUSE_PATCHLEVEL" -eq 1 ]; then # There's no python-PyYaml in SP1, let's install it using pip pip install PyYaml || return 1 fi # PIP based installs need to copy configuration files "by hand". - if [ $SUSE_PATCHLEVEL -eq 1 ]; then + if [ "$SUSE_PATCHLEVEL" -eq 1 ]; then # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then # Let's set the configuration directory to /tmp @@ -3791,17 +3791,17 @@ install_suse_11_stable_deps() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # Syndic uses the same configuration file as the master [ $fname = "syndic" ] && fname=master # Let's download, since they were not provided, the default configuration files - if [ ! -f $_SALT_ETC_DIR/$fname ] && [ ! -f $_TEMP_CONFIG_DIR/$fname ]; then - curl $_CURL_ARGS -s -o $_TEMP_CONFIG_DIR/$fname -L \ - https://raw.githubusercontent.com/saltstack/salt/develop/conf/$fname || return 1 + if [ ! -f "$_SALT_ETC_DIR/$fname" ] && [ ! -f "$_TEMP_CONFIG_DIR/$fname" ]; then + curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/$fname" -L \ + "https://raw.githubusercontent.com/saltstack/salt/develop/conf/$fname" || return 1 fi done fi @@ -3831,7 +3831,7 @@ install_suse_11_git_deps() { } install_suse_11_stable() { - if [ $SUSE_PATCHLEVEL -gt 1 ]; then + if [ "$SUSE_PATCHLEVEL" -gt 1 ]; then install_opensuse_stable || return 1 else # USE_SETUPTOOLS=1 To work around @@ -3847,25 +3847,25 @@ install_suse_11_git() { } install_suse_11_stable_post() { - if [ $SUSE_PATCHLEVEL -gt 1 ]; then + if [ "$SUSE_PATCHLEVEL" -gt 1 ]; then install_opensuse_stable_post || return 1 else for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then - curl $_CURL_ARGS -L https://github.com/saltstack/salt/raw/develop/pkg/salt-$fname.service \ - -o /lib/systemd/system/salt-$fname.service || return 1 + curl $_CURL_ARGS -L "https://github.com/saltstack/salt/raw/develop/pkg/salt-$fname.service" \ + -o "/lib/systemd/system/salt-$fname.service" || return 1 continue fi - curl $_CURL_ARGS -L https://github.com/saltstack/salt/raw/develop/pkg/rpm/salt-$fname \ - -o /etc/init.d/salt-$fname || return 1 - chmod +x /etc/init.d/salt-$fname + curl $_CURL_ARGS -L "https://github.com/saltstack/salt/raw/develop/pkg/rpm/salt-$fname" \ + -o "/etc/init.d/salt-$fname" || return 1 + chmod +x "/etc/init.d/salt-$fname" done fi @@ -3890,9 +3890,9 @@ install_suse_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_systemd salt-$fname || return 1 done return 0 @@ -3907,7 +3907,7 @@ install_suse_check_services() { # Gentoo Install Functions. # __emerge() { - if [ $_GENTOO_USE_BINHOST -eq $BS_TRUE ]; then + if [ "$_GENTOO_USE_BINHOST" -eq $BS_TRUE ]; then emerge --autounmask-write --getbinpkg "${@}"; return $? fi emerge --autounmask-write "${@}"; return $? @@ -3923,7 +3923,7 @@ __gentoo_config_protection() { } __gentoo_pre_dep() { - if [ $_ECHO_DEBUG -eq $BS_TRUE ]; then + if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then if [ "x$(which eix)" != "x" ]; then eix-sync else @@ -3946,7 +3946,7 @@ __gentoo_post_dep() { # the -o option asks it to emerge the deps but not the package. __gentoo_config_protection - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" __emerge -v 'dev-python/pip' pip install -U "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" @@ -3986,9 +3986,9 @@ install_gentoo_post() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -d "/run/systemd/system" ]; then systemctl enable salt-$fname.service @@ -4006,9 +4006,9 @@ install_gentoo_restart_daemons() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -d "/run/systemd/system" ]; then systemctl stop salt-$fname > /dev/null 2>&1 @@ -4028,9 +4028,9 @@ install_gentoo_check_services() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue __check_services_systemd salt-$fname || return 1 done return 0 @@ -4053,8 +4053,8 @@ config_salt() { CONFIGURED_ANYTHING=$BS_FALSE # Let's create the necessary directories - [ -d $_SALT_ETC_DIR ] || mkdir $_SALT_ETC_DIR || return 1 - [ -d $_PKI_DIR ] || mkdir -p $_PKI_DIR && chmod 700 $_PKI_DIR || return 1 + [ -d "$_SALT_ETC_DIR" ] || mkdir "$_SALT_ETC_DIR" || return 1 + [ -d "$_PKI_DIR" ] || mkdir -p "$_PKI_DIR" && chmod 700 "$_PKI_DIR" || return 1 # Copy the grains file if found if [ -f "$_TEMP_CONFIG_DIR/grains" ]; then @@ -4063,54 +4063,54 @@ config_salt() { CONFIGURED_ANYTHING=$BS_TRUE fi - if [ $_INSTALL_MINION -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then # Create the PKI directory - [ -d $_PKI_DIR/minion ] || mkdir -p $_PKI_DIR/minion && chmod 700 $_PKI_DIR/minion || return 1 + [ -d "$_PKI_DIR/minion" ] || mkdir -p "$_PKI_DIR/minion" && chmod 700 "$_PKI_DIR/minion" || return 1 # Copy the minions configuration if found if [ -f "$_TEMP_CONFIG_DIR/minion" ]; then - movefile "$_TEMP_CONFIG_DIR/minion" $_SALT_ETC_DIR || return 1 + movefile "$_TEMP_CONFIG_DIR/minion" "$_SALT_ETC_DIR" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi # Copy the minion's keys if found if [ -f "$_TEMP_CONFIG_DIR/minion.pem" ]; then - movefile "$_TEMP_CONFIG_DIR/minion.pem" $_PKI_DIR/minion/ || return 1 - chmod 400 $_PKI_DIR/minion/minion.pem || return 1 + movefile "$_TEMP_CONFIG_DIR/minion.pem" "$_PKI_DIR/minion/" || return 1 + chmod 400 "$_PKI_DIR/minion/minion.pem" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi if [ -f "$_TEMP_CONFIG_DIR/minion.pub" ]; then - movefile "$_TEMP_CONFIG_DIR/minion.pub" $_PKI_DIR/minion/ || return 1 - chmod 664 $_PKI_DIR/minion/minion.pub || return 1 + movefile "$_TEMP_CONFIG_DIR/minion.pub" "$_PKI_DIR/minion/" || return 1 + chmod 664 "$_PKI_DIR/minion/minion.pub" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi fi - if [ $_INSTALL_MASTER -eq $BS_TRUE ] || [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then # Create the PKI directory - [ -d $_PKI_DIR/master ] || mkdir -p $_PKI_DIR/master && chmod 700 $_PKI_DIR/master || return 1 + [ -d "$_PKI_DIR/master" ] || (mkdir -p "$_PKI_DIR/master" && chmod 700 "$_PKI_DIR/master") || return 1 # Copy the masters configuration if found if [ -f "$_TEMP_CONFIG_DIR/master" ]; then - movefile "$_TEMP_CONFIG_DIR/master" $_SALT_ETC_DIR || return 1 + movefile "$_TEMP_CONFIG_DIR/master" "$_SALT_ETC_DIR" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi # Copy the master's keys if found if [ -f "$_TEMP_CONFIG_DIR/master.pem" ]; then - movefile "$_TEMP_CONFIG_DIR/master.pem" $_PKI_DIR/master/ || return 1 - chmod 400 $_PKI_DIR/master/master.pem || return 1 + movefile "$_TEMP_CONFIG_DIR/master.pem" "$_PKI_DIR/master/" || return 1 + chmod 400 "$_PKI_DIR/master/master.pem" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi if [ -f "$_TEMP_CONFIG_DIR/master.pub" ]; then - movefile "$_TEMP_CONFIG_DIR/master.pub" $_PKI_DIR/master/ || return 1 - chmod 664 $_PKI_DIR/master/master.pub || return 1 + movefile "$_TEMP_CONFIG_DIR/master.pub" "$_PKI_DIR/master/" || return 1 + chmod 664 "$_PKI_DIR/master/master.pub" || return 1 CONFIGURED_ANYTHING=$BS_TRUE fi fi - if [ $_CONFIG_ONLY -eq $BS_TRUE ] && [ $CONFIGURED_ANYTHING -eq $BS_FALSE ]; then + if [ "$_CONFIG_ONLY" -eq $BS_TRUE ] && [ $CONFIGURED_ANYTHING -eq $BS_FALSE ]; then echowarn "No configuration or keys were copied over. No configuration was done!" exit 0 fi @@ -4136,7 +4136,7 @@ preseed_master() { fi SEED_DEST="$_PKI_DIR/master/minions" - [ -d $SEED_DEST ] || mkdir -p $SEED_DEST && chmod 700 $SEED_DEST || return 1 + [ -d "$SEED_DEST" ] || mkdir -p "$SEED_DEST" && chmod 700 "$SEED_DEST" || return 1 for keyfile in $_TEMP_KEYS_DIR/*; do keyfile=$(basename "${keyfile}") @@ -4144,10 +4144,10 @@ preseed_master() { dst_keyfile="${SEED_DEST}/${keyfile}" # If it's not a file, skip to the next - [ ! -f $src_keyfile ] && continue + [ ! -f "$src_keyfile" ] && continue movefile "$src_keyfile" "$dst_keyfile" || return 1 - chmod 664 $dst_keyfile || return 1 + chmod 664 "$dst_keyfile" || return 1 done return 0 @@ -4169,9 +4169,9 @@ daemons_running() { for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # shellcheck disable=SC2009 if [ "${DISTRO_NAME}" = "SmartOS" ]; then @@ -4340,19 +4340,19 @@ done echodebug "CHECK_SERVICES_FUNC=${CHECK_SERVICES_FUNC}" -if [ $DEPS_INSTALL_FUNC = "null" ]; then +if [ "$DEPS_INSTALL_FUNC" = "null" ]; then echoerror "No dependencies installation function found. Exiting..." exit 1 fi -if [ $INSTALL_FUNC = "null" ]; then +if [ "$INSTALL_FUNC" = "null" ]; then echoerror "No installation function found. Exiting..." exit 1 fi # Install dependencies -if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then # Only execute function is not in config mode only echoinfo "Running ${DEPS_INSTALL_FUNC}()" $DEPS_INSTALL_FUNC @@ -4386,7 +4386,7 @@ fi # Install Salt -if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then # Only execute function is not in config mode only echoinfo "Running ${INSTALL_FUNC}()" $INSTALL_FUNC @@ -4398,7 +4398,7 @@ fi # Ensure that the cachedir exists # (Workaround for https://github.com/saltstack/salt/issues/6502) -if [ $_INSTALL_MINION -eq $BS_TRUE ]; then +if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then if [ ! -d /var/cache/salt/minion/proc ]; then echodebug "Creating salt's cachedir" mkdir -p /var/cache/salt/minion/proc @@ -4406,21 +4406,21 @@ if [ $_INSTALL_MINION -eq $BS_TRUE ]; then fi # Drop the master address if passed -if [ $_SALT_MASTER_ADDRESS != "null" ]; then - [ ! -d $_SALT_ETC_DIR/minion.d ] && mkdir -p $_SALT_ETC_DIR/minion.d +if [ "$_SALT_MASTER_ADDRESS" != "null" ]; then + [ ! -d "$_SALT_ETC_DIR/minion.d" ] && mkdir -p "$_SALT_ETC_DIR/minion.d" cat <<_eof > $_SALT_ETC_DIR/minion.d/99-master-address.conf master: $_SALT_MASTER_ADDRESS _eof fi # Drop the minion id if passed -if [ $_SALT_MINION_ID != "null" ]; then - [ ! -d $_SALT_ETC_DIR ] && mkdir -p $_SALT_ETC_DIR - echo $_SALT_MINION_ID > $_SALT_ETC_DIR/minion_id +if [ "$_SALT_MINION_ID" != "null" ]; then + [ ! -d "$_SALT_ETC_DIR" ] && mkdir -p "$_SALT_ETC_DIR" + echo "$_SALT_MINION_ID" > "$_SALT_ETC_DIR/minion_id" fi # Run any post install function. Only execute function if not in config mode only -if [ $_CONFIG_ONLY -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then +if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then echoinfo "Running ${POST_INSTALL_FUNC}()" $POST_INSTALL_FUNC if [ $? -ne 0 ]; then @@ -4430,7 +4430,7 @@ if [ $_CONFIG_ONLY -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then fi # Run any check services function, Only execute function if not in config mode only -if [ $_CONFIG_ONLY -eq $BS_FALSE ] && [ "$CHECK_SERVICES_FUNC" != "null" ]; then +if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$CHECK_SERVICES_FUNC" != "null" ]; then echoinfo "Running ${CHECK_SERVICES_FUNC}()" $CHECK_SERVICES_FUNC if [ $? -ne 0 ]; then @@ -4463,17 +4463,17 @@ if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; th for fname in minion master syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - if [ $_ECHO_DEBUG -eq $BS_FALSE ]; then + if [ "$_ECHO_DEBUG" -eq $BS_FALSE ]; then echoerror "salt-$fname was not found running. Pass '-D' to $__ScriptName when bootstrapping for additional debugging information..." continue fi - [ ! $_SALT_ETC_DIR/$fname ] && [ $fname != "syndic" ] && echodebug "$_SALT_ETC_DIR/$fname does not exist" + [ ! "$_SALT_ETC_DIR/$fname" ] && [ $fname != "syndic" ] && echodebug "$_SALT_ETC_DIR/$fname does not exist" echodebug "Running salt-$fname by hand outputs: $(nohup salt-$fname -l debug)" @@ -4493,7 +4493,7 @@ fi # Done! -if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Salt installed!" else echoinfo "Salt configured"