From a43d1395209b64303ecf4c2028a44a4c67268ea5 Mon Sep 17 00:00:00 2001 From: David Murphy < dmurphy@saltstack.com> Date: Fri, 2 Feb 2024 15:32:40 -0700 Subject: [PATCH] Added support for Amazon 2023 and cleaned up with shellcheck --- bootstrap-salt.sh | 1864 +++++++++++++++++++++++++-------------------- 1 file changed, 1034 insertions(+), 830 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 85f3e7c..1362dbb 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3,6 +3,7 @@ # WARNING: Changes to this file in the salt repo will be overwritten! # Please submit pull requests against the salt-bootstrap repo: # https://github.com/saltstack/salt-bootstrap +# shellcheck disable=SC2317 #====================================================================================================================== # vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120 @@ -132,7 +133,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 @@ -534,7 +535,7 @@ __exit_cleanup() { EXIT_CODE=$? if [ "$ITYPE" = "git" ] && [ -d "${_SALT_GIT_CHECKOUT_DIR}" ]; then - if [ $_KEEP_TEMP_FILES -eq $BS_FALSE ]; then + if [ "$_KEEP_TEMP_FILES" -eq "$BS_FALSE" ]; then # Clean up the checked out repository echodebug "Cleaning up the Salt Temporary Git Repository" # shellcheck disable=SC2164 @@ -563,7 +564,7 @@ __exit_cleanup() { # shellcheck disable=SC2009 TEE_PID=$(ps ax | grep tee | grep "$LOGFILE" | awk '{print $1}') - [ "$TEE_PID" = "" ] && exit $EXIT_CODE + [ "$TEE_PID" = "" ] && exit "$EXIT_CODE" echodebug "Killing logging pipe tee's with pid(s): $TEE_PID" @@ -572,7 +573,7 @@ __exit_cleanup() { __trap_errors() { echoinfo "Errors Trapped: $EXIT_CODE" # Exit with the "original" exit code, not the trapped code - exit $EXIT_CODE + exit "$EXIT_CODE" } trap "__trap_errors" INT ABRT QUIT TERM @@ -580,7 +581,7 @@ __exit_cleanup() { kill -s TERM "$TEE_PID" # In case the 127 errno is not triggered, exit with the "original" exit code - exit $EXIT_CODE + exit "$EXIT_CODE" } trap "__exit_cleanup" EXIT INT @@ -837,7 +838,7 @@ fi # -a and -V only work from git if [ "$ITYPE" != "git" ]; then - if [ $_PIP_ALL -eq $BS_TRUE ]; then + if [ "$_PIP_ALL" -eq "$BS_TRUE" ]; then echoerror "Pip installing all python packages with -a is only possible when installing Salt via git" exit 1 fi @@ -852,14 +853,14 @@ if [ "$_CUSTOM_REPO_URL" != "null" ]; then _REPO_URL="$_CUSTOM_REPO_URL" # Check for -r since -R is being passed. Set -r with a warning. - if [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ]; then echowarn "Detected -R option. No other repositories will be configured when -R is used. Setting -r option to True." - _DISABLE_REPOS=$BS_TRUE + _DISABLE_REPOS="$BS_TRUE" fi fi # Check the _DISABLE_SSL value and set HTTP or HTTPS. -if [ "$_DISABLE_SSL" -eq $BS_TRUE ]; then +if [ "$_DISABLE_SSL" -eq "$BS_TRUE" ]; then HTTP_VAL="http" else HTTP_VAL="https" @@ -1180,7 +1181,7 @@ __gather_linux_system_info() { # We already have the distribution name and version return fi - # shellcheck disable=SC2035,SC2086 + # shellcheck disable=SC2035,SC2086,SC2269 for rsource in $(__sort_release_files "$( cd /etc && /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \ sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \ @@ -1295,7 +1296,7 @@ __install_python() { __PACKAGES="$_PY_PKG_VER" - if [ ${_DISABLE_REPOS} -eq ${BS_FALSE} ]; then + if [ "${_DISABLE_REPOS}" -eq "${BS_FALSE}" ]; then echoinfo "Attempting to install a repo to help provide a separate python package" echoinfo "$DISTRO_NAME_L" case "$DISTRO_NAME_L" in @@ -1995,7 +1996,7 @@ if [ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$_VIRTUALENV_DIR" != "null" ]; then fi # Only Ubuntu has support for pip installing all packages -if [ "${DISTRO_NAME_L}" != "ubuntu" ] && [ $_PIP_ALL -eq $BS_TRUE ]; then +if [ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$_PIP_ALL" -eq "$BS_TRUE" ]; then echoerror "${DISTRO_NAME} does not have -a support" exit 1 fi @@ -2080,7 +2081,7 @@ __wait_for_apt(){ APT_RETURN=$? # Make sure we're not waiting on a lock - while [ $APT_RETURN -ne 0 ] && grep -q '^E: Could not get lock' "$APT_ERR"; do + while [ "$APT_RETURN" -ne 0 ] && grep -q '^E: Could not get lock' "$APT_ERR"; do echoinfo "Aware of the lock. Patiently waiting $WAIT_TIMEOUT more seconds..." sleep 1 WAIT_TIMEOUT=$((WAIT_TIMEOUT - 1)) @@ -2095,7 +2096,7 @@ __wait_for_apt(){ fi done - return $APT_RETURN + return "$APT_RETURN" } #--- FUNCTION ------------------------------------------------------------------------------------------------------- @@ -2133,7 +2134,7 @@ __temp_gpg_pub() { tempfile="/tmp/salt-gpg-$$.pub" fi - echo $tempfile + echo "$tempfile" } # ----------- end of function __temp_gpg_pub ----------- @@ -2368,11 +2369,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 "Overwriting $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 overwriting $dfile with $sfile" fi return 0 @@ -2398,7 +2399,7 @@ __movefile() { exit 1 fi - if [ $_KEEP_TEMP_FILES -eq $BS_TRUE ]; then + if [ "$_KEEP_TEMP_FILES" -eq "$BS_TRUE" ]; then # 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" @@ -2424,11 +2425,11 @@ __movefile() { # The destination file does not exist, move 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 @@ -2474,11 +2475,11 @@ __linkfile() { # The destination file does not exist, create link echodebug "Creating $linkname symlink pointing to $sfile" ln -s "$sfile" "$linkname" || return 1 - elif [ -e "$linkname" ] && [ "$overwrite" -eq $BS_TRUE ]; then + elif [ -e "$linkname" ] && [ "$overwrite" -eq "$BS_TRUE" ]; then # The destination exist and we're overwriting echodebug "Overwriting $linkname symlink to point on $sfile" ln -sf "$sfile" "$linkname" || return 1 - elif [ -e "$linkname" ] && [ "$overwrite" -ne $BS_TRUE ]; then + elif [ -e "$linkname" ] && [ "$overwrite" -ne "$BS_TRUE" ]; then echodebug "Not overwriting $linkname symlink to point on $sfile" fi done @@ -2522,7 +2523,7 @@ __overwriteconfig() { fi # Convert json string to a yaml string and write it to config file. Output is dumped into tempfile. - "$good_python" -c "import json; import yaml; jsn=json.loads('$json'); yml=yaml.safe_dump(jsn, line_break='\\n', default_flow_style=False); config_file=open('$target', 'w'); config_file.write(yml); config_file.close();" 2>$tempfile + "$good_python" -c "import json; import yaml; jsn=json.loads('$json'); yml=yaml.safe_dump(jsn, line_break='\\n', default_flow_style=False); config_file=open('$target', 'w'); config_file.write(yml); config_file.close();" 2>"$tempfile" # No python errors output to the tempfile if [ ! -s "$tempfile" ]; then @@ -2707,7 +2708,7 @@ __check_services_openrc() { __create_virtualenv() { if [ ! -d "$_VIRTUALENV_DIR" ]; then echoinfo "Creating virtualenv ${_VIRTUALENV_DIR}" - if [ $_PIP_ALL -eq $BS_TRUE ]; then + if [ "$_PIP_ALL" -eq "$BS_TRUE" ]; then virtualenv --no-site-packages "${_VIRTUALENV_DIR}" || return 1 else virtualenv --system-site-packages "${_VIRTUALENV_DIR}" || return 1 @@ -2814,7 +2815,7 @@ __install_pip_deps() { fi __PIP_PACKAGES='' - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # shellcheck disable=SC2089 __PIP_PACKAGES="${__PIP_PACKAGES} 'apache-libcloud>=$_LIBCLOUD_MIN_VERSION'" fi @@ -2862,7 +2863,7 @@ import sys try: import pip installed_pip_version=tuple([int(part.strip()) for part in pip.__version__.split('.') if part.isdigit()]) - desired_pip_version=($(echo ${_MINIMUM_PIP_VERSION} | sed 's/\./, /g' )) + desired_pip_version=($(echo "${_MINIMUM_PIP_VERSION}" | sed 's/\./, /g' )) if installed_pip_version < desired_pip_version: print('Desired pip version {!r} > Installed pip version {!r}'.format('.'.join(map(str, desired_pip_version)), '.'.join(map(str, installed_pip_version)))) sys.exit(1) @@ -2877,10 +2878,10 @@ EOM # Upgrade pip to at least 1.2 which is when we can start using "python -m pip" if [ "${_py_version}" = "3.5" ]; then echodebug "Running '${_pip_cmd} install ${_POST_NEON_PIP_INSTALL_ARGS} pip>=${_MINIMUM_PIP_VERSION},<21.0'" - ${_pip_cmd} install ${_POST_NEON_PIP_INSTALL_ARGS} -v "pip>=${_MINIMUM_PIP_VERSION},<21.0" + ${_pip_cmd} install "${_POST_NEON_PIP_INSTALL_ARGS}" -v "pip>=${_MINIMUM_PIP_VERSION},<21.0" else echodebug "Running '${_pip_cmd} install ${_POST_NEON_PIP_INSTALL_ARGS} pip>=${_MINIMUM_PIP_VERSION}'" - ${_pip_cmd} install ${_POST_NEON_PIP_INSTALL_ARGS} -v "pip>=${_MINIMUM_PIP_VERSION}" + ${_pip_cmd} install "${_POST_NEON_PIP_INSTALL_ARGS}" -v "pip>=${_MINIMUM_PIP_VERSION}" fi sleep 1 echodebug "PATH: ${PATH}" @@ -2907,7 +2908,7 @@ EOM fi echodebug "Running '${_pip_cmd} install wheel ${_setuptools_dep}'" - ${_pip_cmd} install --upgrade ${_POST_NEON_PIP_INSTALL_ARGS} wheel "${_setuptools_dep}" + ${_pip_cmd} install --upgrade "${_POST_NEON_PIP_INSTALL_ARGS}" wheel "${_setuptools_dep}" echoinfo "Installing salt using ${_py_exe}" cd "${_SALT_GIT_CHECKOUT_DIR}" || return 1 @@ -2915,21 +2916,21 @@ EOM mkdir /tmp/git/deps echoinfo "Downloading Salt Dependencies from PyPi" echodebug "Running '${_pip_cmd} download -d /tmp/git/deps ${_PIP_DOWNLOAD_ARGS} .'" - ${_pip_cmd} download -d /tmp/git/deps ${_PIP_DOWNLOAD_ARGS} . || (echo "Failed to download salt dependencies" && return 1) + ${_pip_cmd} download -d /tmp/git/deps "${_PIP_DOWNLOAD_ARGS}" . || (echo "Failed to download salt dependencies" && return 1) echoinfo "Installing Downloaded Salt Dependencies" echodebug "Running '${_pip_cmd} install --ignore-installed ${_POST_NEON_PIP_INSTALL_ARGS} /tmp/git/deps/*'" - ${_pip_cmd} install --ignore-installed ${_POST_NEON_PIP_INSTALL_ARGS} /tmp/git/deps/* || return 1 + ${_pip_cmd} install --ignore-installed "${_POST_NEON_PIP_INSTALL_ARGS}" /tmp/git/deps/* || return 1 rm -f /tmp/git/deps/* echoinfo "Building Salt Python Wheel" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then SETUP_PY_INSTALL_ARGS="-v" fi echodebug "Running '${_py_exe} setup.py --salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS} bdist_wheel'" - ${_py_exe} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} bdist_wheel || return 1 + ${_py_exe} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS}" bdist_wheel || return 1 mv dist/salt*.whl /tmp/git/deps/ || return 1 cd "${__SALT_GIT_CHECKOUT_PARENT_DIR}" || return 1 @@ -2938,7 +2939,7 @@ EOM ${_pip_cmd} uninstall --yes salt 2>/dev/null || true echodebug "Running '${_pip_cmd} install --no-deps --force-reinstall ${_POST_NEON_PIP_INSTALL_ARGS} /tmp/git/deps/salt*.whl'" ${_pip_cmd} install --no-deps --force-reinstall \ - ${_POST_NEON_PIP_INSTALL_ARGS} \ + "${_POST_NEON_PIP_INSTALL_ARGS}" \ --global-option="--salt-config-dir=$_SALT_ETC_DIR --salt-cache-dir=${_SALT_CACHE_DIR} ${SETUP_PY_INSTALL_ARGS}" \ /tmp/git/deps/salt*.whl || return 1 @@ -2964,12 +2965,14 @@ EOM } # ---------- end of function __install_salt_from_repo_post_neon ---------- -if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then +if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then + # shellcheck disable=SC2268 if [ "x${_PY_MAJOR_VERSION}" = "x" ]; then # Default to python 2 for pre Neon installs _PY_MAJOR_VERSION=2 fi else + # shellcheck disable=SC2268 if [ "x${_PY_MAJOR_VERSION}" = "x" ]; then # Default to python 3 for post Neon install _PY_MAJOR_VERSION=3 @@ -3167,7 +3170,7 @@ __install_saltstack_ubuntu_onedir_repository() { } install_ubuntu_deps() { - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ]; then # Install add-apt-repository if ! __check_command_exists add-apt-repository; then __apt_get_install_noinput software-properties-common || return 1 @@ -3230,7 +3233,7 @@ install_ubuntu_stable_deps() { _SLEEP=10 fi - if [ $_START_DAEMONS -eq $BS_FALSE ]; then + if [ "$_START_DAEMONS" -eq "$BS_FALSE" ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -3239,8 +3242,8 @@ install_ubuntu_stable_deps() { __wait_for_apt apt-get update || return 1 - if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then - if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then + if [ "${_UPGRADE_SYS}" -eq "$BS_TRUE" ]; then + if [ "${_INSECURE_DL}" -eq "$BS_TRUE" ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 20 ] || [ "$DISTRO_MAJOR_VERSION" -ge 21 ] || [ "$DISTRO_MAJOR_VERSION" -ge 22 ]; then __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1 else @@ -3267,7 +3270,7 @@ install_ubuntu_git_deps() { __apt_get_install_noinput git-core || return 1 fi - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __apt_get_install_noinput ca-certificates fi @@ -3279,12 +3282,12 @@ install_ubuntu_git_deps() { PY_PKG_VER="" fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __PACKAGES="" # See how we are installing packages - if [ "${_PIP_ALL}" -eq $BS_TRUE ]; then + if [ "${_PIP_ALL}" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python-dev swig libssl-dev libzmq3 libzmq3-dev" if ! __check_command_exists pip; then @@ -3312,7 +3315,7 @@ install_ubuntu_git_deps() { __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-zmq" __PACKAGES="${__PACKAGES} python-concurrent.futures" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # Install python-libcloud if asked to __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud" fi @@ -3346,7 +3349,7 @@ install_ubuntu_onedir_deps() { _SLEEP=10 fi - if [ $_START_DAEMONS -eq $BS_FALSE ]; then + if [ "$_START_DAEMONS" -eq "$BS_FALSE" ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -3355,8 +3358,8 @@ install_ubuntu_onedir_deps() { __wait_for_apt apt-get update || return 1 - if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then - if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then + if [ "${_UPGRADE_SYS}" -eq "$BS_TRUE" ]; then + if [ "${_INSECURE_DL}" -eq "$BS_TRUE" ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 20 ] || [ "$DISTRO_MAJOR_VERSION" -ge 21 ]; then __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1 else @@ -3379,21 +3382,21 @@ install_ubuntu_onedir_deps() { install_ubuntu_stable() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 return 0 } @@ -3410,7 +3413,7 @@ install_ubuntu_git() { _PYEXE=python2.7 fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then # We can use --prefix on debian based ditributions if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python3/dist-packages --install-option=--install-scripts=/usr/bin" @@ -3428,16 +3431,16 @@ install_ubuntu_git() { _SERVICE_DIR="pkg" fi - sed -i 's:/usr/bin:/usr/local/bin:g' ${_SERVICE_DIR}/*.service + sed -i 's:/usr/bin:/usr/local/bin:g' "${_SERVICE_DIR}"/*.service return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then # shellcheck disable=SC2086 - "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1 + "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --install-layout=deb || return 1 else # shellcheck disable=SC2086 - "${_PYEXE}" setup.py ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1 + "${_PYEXE}" setup.py "${SETUP_PY_INSTALL_ARGS}" install --install-layout=deb || return 1 fi return 0 @@ -3446,21 +3449,21 @@ install_ubuntu_git() { install_ubuntu_onedir() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 return 0 } @@ -3468,23 +3471,23 @@ install_ubuntu_onedir() { install_ubuntu_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 # Using systemd - /bin/systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || ( - /bin/systemctl preset salt-$fname.service > /dev/null 2>&1 && - /bin/systemctl enable salt-$fname.service > /dev/null 2>&1 + /bin/systemctl is-enabled "salt-$fname.service" > /dev/null 2>&1 || ( + /bin/systemctl preset "salt-$fname.service" > /dev/null 2>&1 && + /bin/systemctl enable "salt-$fname.service" > /dev/null 2>&1 ) sleep 1 /bin/systemctl daemon-reload - elif [ -f /etc/init.d/salt-$fname ]; then - update-rc.d salt-$fname defaults + elif [ -f "/etc/init.d/salt-$fname" ]; then + update-rc.d "salt-$fname defaults" fi done @@ -3494,11 +3497,11 @@ install_ubuntu_stable_post() { install_ubuntu_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -3511,23 +3514,23 @@ install_ubuntu_git_post() { __copyfile "${_SERVICE_DIR}/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service" # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload elif [ -f /sbin/initctl ]; then _upstart_conf="/etc/init/salt-$fname.conf" # We have upstart support echodebug "There's upstart support" - if [ ! -f $_upstart_conf ]; then + if [ ! -f "$_upstart_conf" ]; then # upstart does not know about our service, let's copy the proper file echowarn "Upstart does not appear to know about salt-$fname" echodebug "Copying ${_SERVICE_DIR}/salt-$fname.upstart to $_upstart_conf" __copyfile "${_SERVICE_DIR}/salt-${fname}.upstart" "$_upstart_conf" # Set service to know about virtualenv if [ "${_VIRTUALENV_DIR}" != "null" ]; then - echo "SALT_USE_VIRTUALENV=${_VIRTUALENV_DIR}" > /etc/default/salt-${fname} + echo "SALT_USE_VIRTUALENV=${_VIRTUALENV_DIR}" > "/etc/default/salt-${fname}" fi /sbin/initctl reload-configuration || return 1 fi @@ -3536,12 +3539,12 @@ install_ubuntu_git_post() { echodebug "There's NO upstart support!?" echodebug "Copying ${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.init to /etc/init.d/salt-$fname" __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.init" "/etc/init.d/salt-$fname" - chmod +x /etc/init.d/salt-$fname + chmod +x "/etc/init.d/salt-$fname" # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - update-rc.d salt-$fname defaults + update-rc.d "salt-$fname" defaults else echoerror "Neither upstart nor init.d was setup for salt-$fname" fi @@ -3551,7 +3554,7 @@ install_ubuntu_git_post() { } install_ubuntu_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return # Ensure upstart configs / systemd units are loaded if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 16 ]; then @@ -3562,21 +3565,21 @@ install_ubuntu_restart_daemons() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 16 ]; then echodebug "There's systemd support while checking salt-$fname" - systemctl stop salt-$fname > /dev/null 2>&1 - systemctl start salt-$fname.service && continue + systemctl stop "salt-$fname" > /dev/null 2>&1 + systemctl start "salt-$fname.service" && continue # We failed to start the service, let's test the SysV code below echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi fi @@ -3584,22 +3587,22 @@ install_ubuntu_restart_daemons() { if [ -f /sbin/initctl ]; then echodebug "There's upstart support while checking salt-$fname" - if status salt-$fname 2>/dev/null | grep -q running; then - stop salt-$fname || (echodebug "Failed to stop salt-$fname" && return 1) + if status "salt-$fname" 2>/dev/null | grep -q running; then + stop "salt-$fname" || (echodebug "Failed to stop salt-$fname" && return 1) fi - start salt-$fname && continue + start "salt-$fname" && continue # We failed to start the service, let's test the SysV code below echodebug "Failed to start salt-$fname using Upstart" fi - if [ ! -f /etc/init.d/salt-$fname ]; then + if [ ! -f "/etc/init.d/salt-$fname" ]; then echoerror "No init.d support for salt-$fname was found" return 1 fi - /etc/init.d/salt-$fname stop > /dev/null 2>&1 - /etc/init.d/salt-$fname start + "/etc/init.d/salt-$fname" stop > /dev/null 2>&1 + "/etc/init.d/salt-$fname" start done return 0 @@ -3608,19 +3611,19 @@ install_ubuntu_restart_daemons() { install_ubuntu_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 ] && [ "$DISTRO_MAJOR_VERSION" -ge 16 ]; then - __check_services_systemd salt-$fname || return 1 - elif [ -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 - __check_services_debian salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 + elif [ -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 + __check_services_debian "salt-$fname" || return 1 fi done @@ -3658,7 +3661,7 @@ __install_saltstack_debian_repository() { fi # shellcheck disable=SC2086,SC2090 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/${__PY_VERSION_REPO}/debian/${DEBIAN_RELEASE}/${__REPO_ARCH}" @@ -3692,7 +3695,7 @@ __install_saltstack_debian_onedir_repository() { fi # shellcheck disable=SC2086,SC2090 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/debian/${DEBIAN_RELEASE}/${__REPO_ARCH}/${ONEDIR_REV}/" @@ -3714,7 +3717,7 @@ __install_saltstack_debian_onedir_repository() { } install_debian_deps() { - if [ $_START_DAEMONS -eq $BS_FALSE ]; then + if [ "$_START_DAEMONS" -eq "$BS_FALSE" ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -3723,9 +3726,9 @@ install_debian_deps() { __wait_for_apt apt-get update || return 1 - if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then + if [ "${_UPGRADE_SYS}" -eq "$BS_TRUE" ]; then # Try to update GPG keys first if allowed - if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then + if [ "${_INSECURE_DL}" -eq "$BS_TRUE" ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 10 ]; then __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1 else @@ -3750,7 +3753,7 @@ install_debian_deps() { __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-yaml" # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __check_dpkg_architecture || return 1 @@ -3760,14 +3763,14 @@ install_debian_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + __apt_get_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi return 0 } install_debian_onedir_deps() { - if [ $_START_DAEMONS -eq $BS_FALSE ]; then + if [ "$_START_DAEMONS" -eq "$BS_FALSE" ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -3776,9 +3779,9 @@ install_debian_onedir_deps() { __wait_for_apt apt-get update || return 1 - if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then + if [ "${_UPGRADE_SYS}" -eq "$BS_TRUE" ]; then # Try to update GPG keys first if allowed - if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then + if [ "${_INSECURE_DL}" -eq "$BS_TRUE" ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 10 ]; then __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1 else @@ -3803,7 +3806,7 @@ install_debian_onedir_deps() { __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-yaml" # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __check_dpkg_architecture || return 1 @@ -3813,7 +3816,7 @@ install_debian_onedir_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + __apt_get_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -3824,7 +3827,7 @@ install_debian_git_pre() { __apt_get_install_noinput git || return 1 fi - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __apt_get_install_noinput ca-certificates fi @@ -3847,23 +3850,23 @@ install_debian_git_deps() { PY_PKG_VER="" fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __PACKAGES="libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname" __PACKAGES="${__PACKAGES} python-crypto python-jinja2 python-msgpack python-m2crypto" __PACKAGES="${__PACKAGES} python-requests python-tornado python-yaml python-zmq" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # Install python-libcloud if asked to __PACKAGES="${__PACKAGES} python-libcloud" fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 else __PACKAGES="python${PY_PKG_VER}-dev python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools gcc" echodebug "install_debian_git_deps() Installing ${__PACKAGES}" # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 fi return 0 @@ -3878,7 +3881,7 @@ install_debian_7_git_deps() { install_debian_8_git_deps() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then echodebug "CALLING install_debian_git_deps" install_debian_git_deps || return 1 return 0 @@ -3890,7 +3893,7 @@ install_debian_8_git_deps() { __apt_get_install_noinput git || return 1 fi - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __apt_get_install_noinput ca-certificates fi @@ -3900,7 +3903,7 @@ install_debian_8_git_deps() { __PACKAGES="${__PACKAGES} python-m2crypto python-msgpack python-requests python-systemd" __PACKAGES="${__PACKAGES} python-yaml python-zmq python-concurrent.futures" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # Install python-libcloud if asked to __PACKAGES="${__PACKAGES} python-libcloud" fi @@ -3915,7 +3918,7 @@ install_debian_8_git_deps() { __PACKAGES="${__PACKAGES} python-pip" fi # Attempt to configure backports repo on non-x86_64 system - elif [ $_DISABLE_REPOS -eq $BS_FALSE ] && [ "$DPKG_ARCHITECTURE" != "amd64" ]; then + elif [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] && [ "$DPKG_ARCHITECTURE" != "amd64" ]; then # Check if Debian Backports repo already configured if ! apt-cache policy | grep -q 'Debian Backports'; then echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ @@ -3931,11 +3934,11 @@ install_debian_8_git_deps() { fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086,SC2090 - pip install -U ${__PIP_PACKAGES} || return 1 + pip install -U "${__PIP_PACKAGES}" || return 1 fi # Let's trigger config_salt() @@ -3949,7 +3952,7 @@ install_debian_8_git_deps() { install_debian_9_git_deps() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then install_debian_git_deps || return 1 return 0 fi @@ -3972,7 +3975,7 @@ install_debian_9_git_deps() { __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-msgpack python${PY_PKG_VER}-requests python${PY_PKG_VER}-systemd" __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado python${PY_PKG_VER}-yaml python${PY_PKG_VER}-zmq" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # Install python-libcloud if asked to __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud" fi @@ -3985,7 +3988,7 @@ install_debian_9_git_deps() { install_debian_10_git_deps() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then install_debian_git_deps || return 1 return 0 fi @@ -4003,12 +4006,12 @@ install_debian_10_git_deps() { __PACKAGES="" fi - __install_tornado_pip ${_py}|| return 1 + __install_tornado_pip "${_py}" || return 1 __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-msgpack python${PY_PKG_VER}-jinja2" __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado python${PY_PKG_VER}-yaml python${PY_PKG_VER}-zmq" # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 return 0 } @@ -4016,21 +4019,21 @@ install_debian_10_git_deps() { install_debian_stable() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 return 0 } @@ -4057,7 +4060,7 @@ install_debian_git() { _PYEXE=python fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then # We can use --prefix on debian based ditributions if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python3/dist-packages --install-option=--install-scripts=/usr/bin" @@ -4075,16 +4078,16 @@ install_debian_git() { _SERVICE_DIR="pkg" fi - sed -i 's:/usr/bin:/usr/local/bin:g' ${_SERVICE_DIR}/*.service + sed -i 's:/usr/bin:/usr/local/bin:g' "${_SERVICE_DIR}"/*.service return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then # shellcheck disable=SC2086 - "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1 + "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --install-layout=deb || return 1 else # shellcheck disable=SC2086 - "${_PYEXE}" setup.py ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1 + "${_PYEXE}" setup.py "${SETUP_PY_INSTALL_ARGS}" install --install-layout=deb || return 1 fi } @@ -4106,21 +4109,21 @@ install_debian_9_git() { install_debian_onedir() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput "${__PACKAGES}" || return 1 return 0 } @@ -4129,10 +4132,10 @@ install_debian_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed [ "$fname" = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -4143,15 +4146,15 @@ install_debian_git_post() { # Configure SystemD for Debian 8 "Jessie" and later if [ -f /bin/systemctl ]; then - if [ ! -f /lib/systemd/system/salt-${fname}.service ] || \ - { [ -f /lib/systemd/system/salt-${fname}.service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]; }; then + if [ ! -f "/lib/systemd/system/salt-${fname}.service" ] || \ + { [ -f "/lib/systemd/system/salt-${fname}.service" ] && [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; }; then if [ -f "${_SERVICE_DIR}/salt-${fname}.service" ]; then __copyfile "${_SERVICE_DIR}/salt-${fname}.service" /lib/systemd/system __copyfile "${_SERVICE_DIR}/salt-${fname}.environment" "/etc/default/salt-${fname}" else # workaround before adding Debian-specific unit files to the Salt main repo __copyfile "${_SERVICE_DIR}/salt-${fname}.service" /lib/systemd/system - sed -i -e '/^Type/ s/notify/simple/' /lib/systemd/system/salt-${fname}.service + sed -i -e '/^Type/ s/notify/simple/' "/lib/systemd/system/salt-${fname}.service" fi fi @@ -4159,11 +4162,11 @@ install_debian_git_post() { [ "$fname" = "api" ] && continue /bin/systemctl enable "salt-${fname}.service" - SYSTEMD_RELOAD=$BS_TRUE + SYSTEMD_RELOAD="$BS_TRUE" # Install initscripts for Debian 7 "Wheezy" elif [ ! -f "/etc/init.d/salt-$fname" ] || \ - { [ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; }; then + { [ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; }; then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.init" "/etc/init.d/salt-${fname}" __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.environment" "/etc/default/salt-${fname}" @@ -4190,29 +4193,29 @@ install_debian_2021_post() { } install_debian_restart_daemons() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return 0 for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ]; then # Debian 8 uses systemd - /bin/systemctl stop salt-$fname > /dev/null 2>&1 - /bin/systemctl start salt-$fname.service && continue - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + /bin/systemctl stop "salt-$fname" > /dev/null 2>&1 + /bin/systemctl start "salt-$fname.service" && continue + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi - elif [ -f /etc/init.d/salt-$fname ]; then + elif [ -f "/etc/init.d/salt-$fname" ]; then # Still in SysV init - /etc/init.d/salt-$fname stop > /dev/null 2>&1 - /etc/init.d/salt-$fname start + "/etc/init.d/salt-$fname" stop > /dev/null 2>&1 + "/etc/init.d/salt-$fname" start fi done } @@ -4220,17 +4223,17 @@ install_debian_restart_daemons() { install_debian_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ]; then - __check_services_systemd salt-$fname || return 1 - elif [ -f /etc/init.d/salt-$fname ]; then - __check_services_debian salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 + elif [ -f "/etc/init.d/salt-$fname" ]; then + __check_services_debian "salt-$fname" || return 1 fi done return 0 @@ -4261,7 +4264,7 @@ __install_saltstack_fedora_onedir_repository() { REPO_FILE="/etc/yum.repos.d/salt.repo" - if [ ! -s "$REPO_FILE" ] || [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then + if [ ! -s "$REPO_FILE" ] || [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; then FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/fedora/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/${ONEDIR_REV}" if [ "${ONEDIR_REV}" = "nightly" ] ; then FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/fedora/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/" @@ -4281,7 +4284,7 @@ __install_saltstack_fedora_onedir_repository() { } install_fedora_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then dnf -y update || return 1 fi @@ -4303,7 +4306,7 @@ install_fedora_deps() { fi # shellcheck disable=SC2086 - __dnf_install_noinput ${__PACKAGES} ${_EXTRA_PACKAGES} || return 1 + __dnf_install_noinput "${__PACKAGES}" "${_EXTRA_PACKAGES}" || return 1 return 0 } @@ -4313,6 +4316,7 @@ install_fedora_stable() { __SALT_VERSION="" else __SALT_VERSION="$(dnf list --showduplicates salt | grep "$STABLE_REV" | head -n 1 | awk '{print $2}')" + # shellcheck disable=SC2268 if [ "x${__SALT_VERSION}" = "x" ]; then echoerror "Could not find a stable install for Salt ${STABLE_REV}" exit 1 @@ -4322,21 +4326,21 @@ install_fedora_stable() { fi __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud${__SALT_VERSION}" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master${__SALT_VERSION}" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion${__SALT_VERSION}" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic${__SALT_VERSION}" fi # shellcheck disable=SC2086 - __dnf_install_noinput ${__PACKAGES} || return 1 + __dnf_install_noinput "${__PACKAGES}" || return 1 __python="python3" if ! __check_command_exists python3; then @@ -4344,9 +4348,9 @@ install_fedora_stable() { return 1 fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __check_pip_allowed "You need to allow pip based installations (-P) for Tornado <5.0 in order to install Salt" - __installed_tornado_rpm=$(rpm -qa | grep python${PY_PKG_VER}-tornado) + __installed_tornado_rpm=$(rpm -qa | grep "python${PY_PKG_VER}-tornado") if [ -n "${__installed_tornado_rpm}" ]; then echodebug "Removing system package ${__installed_tornado_rpm}" rpm -e --nodeps "${__installed_tornado_rpm}" || return 1 @@ -4367,14 +4371,14 @@ EOM install_fedora_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload done @@ -4398,18 +4402,18 @@ install_fedora_git_deps() { if [ -n "${__PACKAGES}" ]; then # shellcheck disable=SC2086 - __dnf_install_noinput ${__PACKAGES} || return 1 + __dnf_install_noinput "${__PACKAGES}" || return 1 __PACKAGES="" fi __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __PACKAGES="${__PACKAGES} ca-certificates" fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud python${PY_PKG_VER}-netaddr" fi @@ -4443,7 +4447,7 @@ install_fedora_git_deps() { __PACKAGES="${__PACKAGES} gcc-c++" fi # shellcheck disable=SC2086 - __dnf_install_noinput ${__PACKAGES} || return 1 + __dnf_install_noinput "${__PACKAGES}" || return 1 fi # Let's trigger config_salt() @@ -4463,15 +4467,15 @@ install_fedora_git() { _PYEXE='python2' fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - ${_PYEXE} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + ${_PYEXE} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 else - ${_PYEXE} setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + ${_PYEXE} setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 fi return 0 } @@ -4479,11 +4483,11 @@ install_fedora_git() { install_fedora_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -4499,31 +4503,31 @@ install_fedora_git_post() { #fi # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload done } install_fedora_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 && continue + systemctl stop "salt-$fname" > /dev/null 2>&1 + systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi done @@ -4532,14 +4536,14 @@ install_fedora_restart_daemons() { install_fedora_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 done return 0 @@ -4547,7 +4551,7 @@ install_fedora_check_services() { install_fedora_onedir_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi @@ -4577,12 +4581,12 @@ install_fedora_onedir_deps() { __PACKAGES="${__PACKAGES} procps" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -4591,32 +4595,32 @@ install_fedora_onedir_deps() { install_fedora_onedir() { - STABLE_REV=$ONEDIR_REV + STABLE_REV="$ONEDIR_REV" #install_fedora_stable || return 1 __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ];then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ];then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 return 0 } install_fedora_onedir_post() { - STABLE_REV=$ONEDIR_REV + STABLE_REV="$ONEDIR_REV" install_fedora_stable_post || return 1 return 0 @@ -4666,7 +4670,7 @@ __install_saltstack_rhel_repository() { repo_file="/etc/yum.repos.d/salt.repo" - if [ ! -s "$repo_file" ] || [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then + if [ ! -s "$repo_file" ] || [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; then cat <<_eof > "$repo_file" [saltstack] name=SaltStack ${repo_rev} Release Channel for RHEL/CentOS \$releasever @@ -4727,7 +4731,7 @@ __install_saltstack_rhel_onedir_repository() { repo_file="/etc/yum.repos.d/salt.repo" - if [ ! -s "$repo_file" ] || [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then + if [ ! -s "$repo_file" ] || [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; then cat <<_eof > "$repo_file" [saltstack] name=SaltStack ${repo_rev} Release Channel for RHEL/CentOS \$releasever @@ -4757,7 +4761,7 @@ _eof } install_centos_stable_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi @@ -4784,7 +4788,7 @@ install_centos_stable_deps() { __PACKAGES="yum-utils chkconfig" fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then # YAML module is used for generating custom master/minion configs if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then @@ -4812,12 +4816,12 @@ install_centos_stable_deps() { __PACKAGES="${__PACKAGES} procps" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi @@ -4827,21 +4831,21 @@ install_centos_stable_deps() { install_centos_stable() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ];then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ];then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 # Workaround for 3.11 broken on CentOS Stream 8.x # Re-install Python 3.6 @@ -4858,26 +4862,26 @@ install_centos_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ]; then - /bin/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( - /bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && - /bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 + /bin/systemctl is-enabled "salt-${fname}.service" > /dev/null 2>&1 || ( + /bin/systemctl preset "salt-${fname}.service" > /dev/null 2>&1 && + /bin/systemctl enable "salt-${fname}.service" > /dev/null 2>&1 ) SYSTEMD_RELOAD=$BS_TRUE elif [ -f "/etc/init.d/salt-${fname}" ]; then - /sbin/chkconfig salt-${fname} on + /sbin/chkconfig "salt-${fname}" on fi done - if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then + if [ "$SYSTEMD_RELOAD" -eq "$BS_TRUE" ]; then /bin/systemctl daemon-reload fi @@ -4890,11 +4894,11 @@ install_centos_git_deps() { # package repos available. # Set ONEDIR_REV to STABLE_REV in case we # end up calling install_centos_onedir_deps - ONEDIR_REV=${STABLE_REV} + ONEDIR_REV="${STABLE_REV}" install_centos_onedir_deps || \ return 1 - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __yum_install_noinput ca-certificates || return 1 fi @@ -4928,7 +4932,7 @@ install_centos_git_deps() { fi fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then _install_m2crypto_req=false if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then _py=${_PY_EXE} @@ -4951,7 +4955,7 @@ install_centos_git_deps() { fi if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then - __install_tornado_pip ${_py} || return 1 + __install_tornado_pip "${_py}" || return 1 __PACKAGES="${__PACKAGES} python3-m2crypto" else __PACKAGES="${__PACKAGES} m2crypto python${PY_PKG_VER}-crypto" @@ -4961,7 +4965,7 @@ install_centos_git_deps() { __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-msgpack python${PY_PKG_VER}-requests" __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado python${PY_PKG_VER}-zmq" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud" fi @@ -4975,7 +4979,7 @@ install_centos_git_deps() { _PIP_PACKAGES="m2crypto!=0.33.0 jinja2 msgpack-python pycrypto PyYAML tornado<5.0 zmq futures>=2.0" # install swig and openssl on cent6 - if $_install_m2crypto_req; then + if "$_install_m2crypto_req"; then __yum_install_noinput openssl-devel swig || return 1 fi @@ -4997,7 +5001,7 @@ install_centos_git_deps() { __install_pip_pkgs "${_PIP_PACKAGES}" "${_PY_EXE}" || return 1 else # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi else if [ "${_INSTALL_PY}" -eq "${BS_TRUE}" ] && [ "$DISTRO_MAJOR_VERSION" -lt 8 ]; then @@ -5006,7 +5010,7 @@ install_centos_git_deps() { fi __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-devel python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools gcc" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi # Let's trigger config_salt() @@ -5027,15 +5031,15 @@ install_centos_git() { fi echodebug "_PY_EXE: $_PY_EXE" - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - $_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + $_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 else - $_PYEXE setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + $_PYEXE setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 fi return 0 @@ -5046,11 +5050,11 @@ install_centos_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -5060,19 +5064,19 @@ install_centos_git_post() { fi if [ -f /bin/systemctl ]; then if [ ! -f "/usr/lib/systemd/system/salt-${fname}.service" ] || \ - { [ -f "/usr/lib/systemd/system/salt-${fname}.service" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; }; then + { [ -f "/usr/lib/systemd/system/salt-${fname}.service" ] && [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; }; then __copyfile "${_SERVICE_FILE}" /usr/lib/systemd/system fi - SYSTEMD_RELOAD=$BS_TRUE + SYSTEMD_RELOAD="$BS_TRUE" elif [ ! -f "/etc/init.d/salt-$fname" ] || \ - { [ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; }; then + { [ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; }; then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d - chmod +x /etc/init.d/salt-${fname} + chmod +x "/etc/init.d/salt-${fname}" fi done - if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then + if [ "$SYSTEMD_RELOAD" -eq "$BS_TRUE" ]; then /bin/systemctl daemon-reload fi @@ -5082,7 +5086,7 @@ install_centos_git_post() { } install_centos_onedir_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi @@ -5112,12 +5116,12 @@ install_centos_onedir_deps() { __PACKAGES="${__PACKAGES} procps" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi @@ -5127,50 +5131,50 @@ install_centos_onedir_deps() { install_centos_onedir() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ];then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ];then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 return 0 } install_centos_onedir_post() { - SYSTEMD_RELOAD=$BS_FALSE + SYSTEMD_RELOAD="$BS_FALSE" for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ]; then - /bin/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( - /bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && - /bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 + /bin/systemctl is-enabled "salt-${fname}.service" > /dev/null 2>&1 || ( + /bin/systemctl preset "salt-${fname}.service" > /dev/null 2>&1 && + /bin/systemctl enable "salt-${fname}.service" > /dev/null 2>&1 ) SYSTEMD_RELOAD=$BS_TRUE elif [ -f "/etc/init.d/salt-${fname}" ]; then - /sbin/chkconfig salt-${fname} on + "/sbin/chkconfig salt-${fname}" on fi done - if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then + if [ "$SYSTEMD_RELOAD" -eq "$BS_TRUE" ]; then /bin/systemctl daemon-reload fi @@ -5178,43 +5182,43 @@ install_centos_onedir_post() { } install_centos_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then + if [ -f /sbin/initctl ] && [ -f "/etc/init/salt-${fname}.conf" ]; then # We have upstart support and upstart knows about our service - if ! /sbin/initctl status salt-$fname > /dev/null 2>&1; then + if ! /sbin/initctl status "salt-$fname" > /dev/null 2>&1; then # Everything is in place and upstart gave us an error code? Fail! return 1 fi # upstart knows about this service. # Let's try to stop it, and then start it - /sbin/initctl stop salt-$fname > /dev/null 2>&1 + /sbin/initctl stop "salt-$fname" > /dev/null 2>&1 # Restart service - if ! /sbin/initctl start salt-$fname > /dev/null 2>&1; then + if ! /sbin/initctl start "salt-$fname" > /dev/null 2>&1; then # Failed the restart?! return 1 fi - elif [ -f /etc/init.d/salt-$fname ]; then + elif [ -f "/etc/init.d/salt-$fname" ]; then # Disable stdin to fix shell session hang on killing tee pipe - service salt-$fname stop < /dev/null > /dev/null 2>&1 - service salt-$fname start < /dev/null + service "salt-$fname" stop < /dev/null > /dev/null 2>&1 + service "salt-$fname" start < /dev/null elif [ -f /usr/bin/systemctl ]; then # CentOS 7 uses systemd - /usr/bin/systemctl stop salt-$fname > /dev/null 2>&1 - /usr/bin/systemctl start salt-$fname.service && continue + /usr/bin/systemctl stop "salt-$fname" > /dev/null 2>&1 + /usr/bin/systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi fi @@ -5239,19 +5243,19 @@ install_centos_testing_post() { install_centos_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 - __check_services_sysvinit salt-$fname || return 1 + 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 + __check_services_sysvinit "salt-$fname" || return 1 elif [ -f /usr/bin/systemctl ]; then - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 fi done @@ -5561,12 +5565,12 @@ install_red_hat_enterprise_workstation_testing_post() { # install_oracle_linux_stable_deps() { # Install Oracle's EPEL. - if [ ${_EPEL_REPOS_INSTALLED} -eq $BS_FALSE ]; then - _EPEL_REPO=oracle-epel-release-el${DISTRO_MAJOR_VERSION} + if [ "${_EPEL_REPOS_INSTALLED}" -eq "$BS_FALSE" ]; then + _EPEL_REPO="oracle-epel-release-el${DISTRO_MAJOR_VERSION}" if ! rpm -q "${_EPEL_REPO}" > /dev/null; then __yum_install_noinput "${_EPEL_REPO}" fi - _EPEL_REPOS_INSTALLED=$BS_TRUE + _EPEL_REPOS_INSTALLED="$BS_TRUE" fi install_centos_stable_deps || return 1 @@ -5975,7 +5979,7 @@ install_alpine_linux_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then apk -U add python2 py-virtualenv py2-crypto py2-m2crypto py2-setuptools \ py2-jinja2 py2-yaml py2-markupsafe py2-msgpack py2-psutil \ py2-zmq zeromq py2-requests || return 1 @@ -6003,46 +6007,46 @@ install_alpine_linux_git_deps() { install_alpine_linux_stable() { __PACKAGES="salt" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - apk -U add ${__PACKAGES} || return 1 + apk -U add "${__PACKAGES}" || return 1 return 0 } install_alpine_linux_git() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install || return 1 else - python2 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + python2 setup.py "${SETUP_PY_INSTALL_ARGS}" install || return 1 fi } install_alpine_linux_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /sbin/rc-update ]; then script_url="${_SALTSTACK_REPO_URL%.git}/raw/master/pkg/alpine/salt-$fname" @@ -6057,7 +6061,7 @@ install_alpine_linux_post() { fi # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue /sbin/rc-update add "salt-$fname" > /dev/null 2>&1 || return 1 fi @@ -6065,60 +6069,60 @@ install_alpine_linux_post() { } install_alpine_linux_restart_daemons() { - [ "${_START_DAEMONS}" -eq $BS_FALSE ] && return + [ "${_START_DAEMONS}" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Disable stdin to fix shell session hang on killing tee pipe - /sbin/rc-service salt-$fname stop < /dev/null > /dev/null 2>&1 - /sbin/rc-service salt-$fname start < /dev/null || return 1 + /sbin/rc-service "salt-$fname" stop < /dev/null > /dev/null 2>&1 + /sbin/rc-service "salt-$fname" start < /dev/null || return 1 done } install_alpine_linux_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_openrc salt-$fname || return 1 + __check_services_openrc "salt-$fname" || return 1 done return 0 } daemons_running_alpine_linux() { - [ "${_START_DAEMONS}" -eq $BS_FALSE ] && return + [ "${_START_DAEMONS}" -eq "$BS_FALSE" ] && return FAILED_DAEMONS=0 for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 [ "$(ps wwwaux | grep -v grep | grep salt-$fname)" = "" ]; then + if [ "$(ps wwwaux | grep -v grep | grep "salt-$fname")" = "" ]; then echoerror "salt-$fname was not found running" FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) fi done - return $FAILED_DAEMONS + return "$FAILED_DAEMONS" } # @@ -6132,9 +6136,10 @@ daemons_running_alpine_linux() { # Amazon Linux AMI Install Functions # +# Support for Amazon Linux (EOL) install_amazon_linux_ami_deps() { # Shim to figure out if we're using old (rhel) or new (aws) rpms. - _USEAWS=$BS_FALSE + _USEAWS="$BS_FALSE" pkg_append="python" if [ "$ITYPE" = "stable" ]; then @@ -6143,7 +6148,7 @@ install_amazon_linux_ami_deps() { repo_rev="latest" fi - if echo $repo_rev | grep -E -q '^archive'; then + if echo "$repo_rev" | grep -E -q '^archive'; then year=$(echo "$repo_rev" | cut -d '/' -f 2 | cut -c1-4) else year=$(echo "$repo_rev" | cut -c1-4) @@ -6151,7 +6156,7 @@ install_amazon_linux_ami_deps() { if echo "$repo_rev" | grep -E -q '^(latest|2016\.11)$' || \ [ "$year" -gt 2016 ]; then - _USEAWS=$BS_TRUE + _USEAWS="$BS_TRUE" pkg_append="python27" fi @@ -6160,15 +6165,15 @@ install_amazon_linux_ami_deps() { __yum_install_noinput yum-utils # Do upgrade early - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi - if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __REPO_FILENAME="salt.repo" # Set a few vars to make life easier. - if [ $_USEAWS -eq $BS_TRUE ]; then + if [ "$_USEAWS" -eq "$BS_TRUE" ]; then base_url="$HTTP_VAL://${_REPO_URL}/yum/amazon/latest/\$basearch/$repo_rev/" gpg_key="${base_url}SALTSTACK-GPG-KEY.pub" repo_name="SaltStack repo for Amazon Linux" @@ -6195,25 +6200,25 @@ _eof fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then # Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 # which is already installed __PACKAGES="m2crypto ${pkg_append}-crypto ${pkg_append}-jinja2 ${pkg_append}-PyYAML" __PACKAGES="${__PACKAGES} ${pkg_append}-msgpack ${pkg_append}-requests ${pkg_append}-zmq" __PACKAGES="${__PACKAGES} ${pkg_append}-futures" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi } install_amazon_linux_ami_git_deps() { - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then yum -y install ca-certificates || return 1 fi @@ -6237,11 +6242,11 @@ install_amazon_linux_ami_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __PACKAGES="" __PIP_PACKAGES="" - 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} python27-pip" __PIP_PACKAGES="${__PIP_PACKAGES} apache-libcloud>=$_LIBCLOUD_MIN_VERSION" @@ -6257,17 +6262,17 @@ install_amazon_linux_ami_git_deps() { if [ "${__PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - ${PIP_EXE} install ${__PIP_PACKAGES} || return 1 + ${PIP_EXE} install "${__PIP_PACKAGES}" || return 1 fi else __PACKAGES="python27-pip python27-setuptools python27-devel gcc" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi # Let's trigger config_salt() @@ -6279,8 +6284,44 @@ install_amazon_linux_ami_git_deps() { return 0 } +install_amazon_linux_ami_stable() { + install_centos_stable || return 1 + return 0 +} + +install_amazon_linux_ami_stable_post() { + install_centos_stable_post || return 1 + return 0 +} + +install_amazon_linux_ami_restart_daemons() { + install_centos_restart_daemons || return 1 + return 0 +} + +install_amazon_linux_ami_git() { + install_centos_git || return 1 + return 0 +} + +install_amazon_linux_ami_git_post() { + install_centos_git_post || return 1 + return 0 +} + +install_amazon_linux_ami_testing() { + install_centos_testing || return 1 + return 0 +} + +install_amazon_linux_ami_testing_post() { + install_centos_testing_post || return 1 + return 0 +} + +# Support for Amazon Linux 2 install_amazon_linux_ami_2_git_deps() { - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then yum -y install ca-certificates || return 1 fi @@ -6297,7 +6338,7 @@ install_amazon_linux_ami_2_git_deps() { if ! __check_command_exists "${PIP_EXE}"; then # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if ! __check_command_exists git; then @@ -6306,7 +6347,7 @@ install_amazon_linux_ami_2_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __PACKAGES="" __PIP_PACKAGES="" @@ -6345,17 +6386,17 @@ install_amazon_linux_ami_2_git_deps() { if [ "${__PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - ${PIP_EXE} install ${__PIP_PACKAGES} || return 1 + ${PIP_EXE} install "${__PIP_PACKAGES}" || return 1 fi else __PACKAGES="python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools python${PY_PKG_VER}-devel gcc" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi # Let's trigger config_salt() @@ -6369,7 +6410,7 @@ install_amazon_linux_ami_2_git_deps() { install_amazon_linux_ami_2_deps() { # Shim to figure out if we're using old (rhel) or new (aws) rpms. - _USEAWS=$BS_FALSE + _USEAWS="$BS_FALSE" pkg_append="python" if [ "$ITYPE" = "stable" ]; then @@ -6378,7 +6419,7 @@ install_amazon_linux_ami_2_deps() { repo_rev="latest" fi - if echo $repo_rev | grep -E -q '^archive'; then + if echo "$repo_rev" | grep -E -q '^archive'; then year=$(echo "$repo_rev" | cut -d '/' -f 2 | cut -c1-4) else year=$(echo "$repo_rev" | cut -c1-4) @@ -6386,7 +6427,7 @@ install_amazon_linux_ami_2_deps() { if echo "$repo_rev" | grep -E -q '^(latest|2016\.11)$' || \ [ "$year" -gt 2016 ]; then - _USEAWS=$BS_TRUE + _USEAWS="$BS_TRUE" pkg_append="python" fi @@ -6395,11 +6436,11 @@ install_amazon_linux_ami_2_deps() { __yum_install_noinput yum-utils # Do upgrade early - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi - if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __REPO_FILENAME="salt.repo" __PY_VERSION_REPO="yum" PY_PKG_VER="" @@ -6436,7 +6477,7 @@ _eof fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then # Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 # which is already installed if [ -n "${PY_PKG_VER}" ] && [ "${PY_PKG_VER}" -eq 3 ]; then @@ -6449,19 +6490,19 @@ _eof __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-msgpack ${pkg_append}${PY_PKG_VER}-requests ${pkg_append}${PY_PKG_VER}-zmq" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi } install_amazon_linux_ami_2_onedir_deps() { # Shim to figure out if we're using old (rhel) or new (aws) rpms. - _USEAWS=$BS_FALSE + _USEAWS="$BS_FALSE" pkg_append="python" if [ "$ITYPE" = "onedir" ]; then @@ -6470,7 +6511,7 @@ install_amazon_linux_ami_2_onedir_deps() { repo_rev="latest" fi - if echo $repo_rev | grep -E -q '^archive'; then + if echo "$repo_rev" | grep -E -q '^archive'; then year=$(echo "$repo_rev" | cut -d '/' -f 2 | cut -c1-4) else year=$(echo "$repo_rev" | cut -c1-4) @@ -6481,11 +6522,11 @@ install_amazon_linux_ami_2_onedir_deps() { __yum_install_noinput yum-utils # Do upgrade early - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then yum -y update || return 1 fi - if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then __REPO_FILENAME="salt.repo" __PY_VERSION_REPO="yum" PY_PKG_VER="" @@ -6530,7 +6571,7 @@ _eof fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then # Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 # which is already installed if [ -n "${PY_PKG_VER}" ] && [ "${PY_PKG_VER}" -eq 3 ]; then @@ -6543,51 +6584,16 @@ _eof __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-msgpack ${pkg_append}${PY_PKG_VER}-requests ${pkg_append}${PY_PKG_VER}-zmq" # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + __yum_install_noinput "${__PACKAGES}" || return 1 fi if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __yum_install_noinput ${_EXTRA_PACKAGES} || return 1 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi } -install_amazon_linux_ami_stable() { - install_centos_stable || return 1 - return 0 -} - -install_amazon_linux_ami_stable_post() { - install_centos_stable_post || return 1 - return 0 -} - -install_amazon_linux_ami_restart_daemons() { - install_centos_restart_daemons || return 1 - return 0 -} - -install_amazon_linux_ami_git() { - install_centos_git || return 1 - return 0 -} - -install_amazon_linux_ami_git_post() { - install_centos_git_post || return 1 - return 0 -} - -install_amazon_linux_ami_testing() { - install_centos_testing || return 1 - return 0 -} - -install_amazon_linux_ami_testing_post() { - install_centos_testing_post || return 1 - return 0 -} - install_amazon_linux_ami_2_stable() { install_centos_stable || return 1 return 0 @@ -6638,6 +6644,204 @@ install_amazon_linux_ami_2_onedir_post() { return 0 } +# Support for Amazon Linux 2023 +# the following code needs adjustment to allow for 2023, 2024, 2025, etc - 2023 for now +install_amazon_linux_ami_2023_git_deps() { + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + yum -y install ca-certificates || return 1 + fi + + install_amazon_linux_ami_2023_onedir_deps || return 1 + + PY_PKG_VER=3 + PIP_EXE='/bin/pip3' + __PACKAGES="python${PY_PKG_VER}-pip" + + if ! __check_command_exists "${PIP_EXE}"; then + # shellcheck disable=SC2086 + __yum_install_noinput "${__PACKAGES}" || return 1 + fi + + if ! __check_command_exists git; then + __yum_install_noinput git || return 1 + fi + + __git_clone_and_checkout || return 1 + + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then + + __PACKAGES="" + __PIP_PACKAGES="" + + 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} python3-pip" + __PIP_PACKAGES="${__PIP_PACKAGES} tornado<$_TORNADO_MAX_PY3_VERSION" + __PIP_PACKAGES="${__PIP_PACKAGES} apache-libcloud>=$_LIBCLOUD_MIN_VERSION" + fi + + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then + # We're on the master branch, install whichever tornado is on the requirements file + __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" + if [ "${__REQUIRED_TORNADO}" != "" ]; then + __PIP_PACKAGES="${__PIP_PACKAGES} tornado<$_TORNADO_MAX_PY3_VERSION" + fi + fi + + if [ "${__PIP_PACKAGES}" != "" ]; then + __check_pip_allowed "You need to allow pip based installations (-P) in order to install ${__PIP_PACKAGES}" + __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-pip" + fi + + if [ "${__PACKAGES}" != "" ]; then + # shellcheck disable=SC2086 + __yum_install_noinput "${__PACKAGES}" || return 1 + fi + + if [ "${__PIP_PACKAGES}" != "" ]; then + # shellcheck disable=SC2086 + ${PIP_EXE} install "${__PIP_PACKAGES}" || return 1 + fi + else + __PACKAGES="python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools python${PY_PKG_VER}-devel gcc" + # shellcheck disable=SC2086 + __yum_install_noinput "${__PACKAGES}" || return 1 + fi + + # Let's trigger config_salt() + if [ "$_TEMP_CONFIG_DIR" = "null" ]; then + _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" + CONFIG_SALT_FUNC="config_salt" + fi + + return 0 +} + +install_amazon_linux_ami_2023_onedir_deps() { + # Shim to figure out if we're using old (rhel) or new (aws) rpms. + _USEAWS="$BS_FALSE" + pkg_append="python" + + if [ "$ITYPE" = "onedir" ]; then + repo_rev="$ONEDIR_REV" + else + repo_rev="latest" + fi + + if echo "$repo_rev" | grep -E -q '^archive'; then + year=$(echo "$repo_rev" | cut -d '/' -f 2 | cut -c1-4) + else + year=$(echo "$repo_rev" | cut -c1-4) + fi + + # We need to install yum-utils before doing anything else when installing on + # Amazon Linux ECS-optimized images. See issue #974. + __yum_install_noinput yum-utils + + # Do upgrade early + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then + yum -y update || return 1 + fi + + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then + __REPO_FILENAME="salt.repo" + __PY_VERSION_REPO="yum" + __PY_VERSION_REPO="py3" + PY_PKG_VER=3 + repo_label="saltstack-py3-repo" + repo_name="SaltStack Python 3 repo for Amazon Linux 2023" + + base_url="$HTTP_VAL://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/amazon/2023/\$basearch/$repo_rev/" + if [ "${ONEDIR_REV}" = "nightly" ] ; then + base_url="$HTTP_VAL://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/amazon/2023/\$basearch/" + fi + + gpg_key="${base_url}SALT-PROJECT-GPG-PUBKEY-2023.pub" + + # This should prob be refactored to use __install_saltstack_rhel_repository() + # With args passed in to do the right thing. Reformatted to be more like the + # amazon linux yum file. + if [ ! -s "/etc/yum.repos.d/${__REPO_FILENAME}" ]; then + cat <<_eof > "/etc/yum.repos.d/${__REPO_FILENAME}" +[$repo_label] +name=$repo_name +failovermethod=priority +priority=10 +gpgcheck=1 +gpgkey=$gpg_key +baseurl=$base_url +_eof + fi + fi + + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then + # Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 + # which is already installed + __PACKAGES="${pkg_append}${PY_PKG_VER}-m2crypto ${pkg_append}${PY_PKG_VER}-pyyaml" + __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-crypto ${pkg_append}${PY_PKG_VER}-jinja2 procps-ng" + __PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-msgpack ${pkg_append}${PY_PKG_VER}-requests ${pkg_append}${PY_PKG_VER}-zmq" + + # shellcheck disable=SC2086 + __yum_install_noinput "${__PACKAGES}" || return 1 + fi + + if [ "${_EXTRA_PACKAGES}" != "" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + # shellcheck disable=SC2086 + __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1 + fi +} + +install_amazon_linux_ami_2023_stable() { + install_centos_stable || return 1 + return 0 +} + +install_amazon_linux_ami_2023_stable_post() { + install_centos_stable_post || return 1 + return 0 +} + +install_amazon_linux_ami_2023_restart_daemons() { + install_centos_restart_daemons || return 1 + return 0 +} + +install_amazon_linux_ami_2023_git() { + install_centos_git || return 1 + return 0 +} + +install_amazon_linux_ami_2023_git_post() { + install_centos_git_post || return 1 + return 0 +} + +install_amazon_linux_ami_2023_testing() { + install_centos_testing || return 1 + return 0 +} + +install_amazon_linux_ami_2023_testing_post() { + install_centos_testing_post || return 1 + return 0 +} + +install_amazon_linux_ami_2023_check_services() { + install_centos_check_services || return 1 + return 0 +} + +install_amazon_linux_ami_2023_onedir() { + install_centos_stable || return 1 + return 0 +} + +install_amazon_linux_ami_2023_onedir_post() { + install_centos_stable_post || return 1 + return 0 +} + # # Ended Amazon Linux AMI Install Functions # @@ -6674,7 +6878,7 @@ install_arch_linux_stable_deps() { # shellcheck disable=SC2086 pacman -Su --noconfirm --needed python${PY_PKG_VER}-yaml - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # shellcheck disable=SC2086 pacman -Su --noconfirm --needed python${PY_PKG_VER}-apache-libcloud || return 1 fi @@ -6682,7 +6886,7 @@ install_arch_linux_stable_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - pacman -Su --noconfirm --needed ${_EXTRA_PACKAGES} || return 1 + pacman -Su --noconfirm --needed "${_EXTRA_PACKAGES}" || return 1 fi } @@ -6696,7 +6900,7 @@ install_arch_linux_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then pacman -R --noconfirm python2-distribute pacman -Su --noconfirm --needed python2-crypto python2-setuptools python2-jinja \ python2-m2crypto python2-markupsafe python2-msgpack python2-psutil \ @@ -6717,7 +6921,7 @@ install_arch_linux_git_deps() { fi __PACKAGES="python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools gcc" # shellcheck disable=SC2086 - pacman -Su --noconfirm --needed ${__PACKAGES} + pacman -Su --noconfirm --needed "${__PACKAGES}" fi # Let's trigger config_salt() @@ -6753,15 +6957,15 @@ install_arch_linux_git() { _POST_NEON_PIP_INSTALL_ARGS="${_POST_NEON_PIP_INSTALL_ARGS} --use-pep517" _PIP_DOWNLOAD_ARGS="${_PIP_DOWNLOAD_ARGS} --use-pep517" - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install || return 1 else - python2 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + python2 setup.py "${SETUP_PY_INSTALL_ARGS}" install || return 1 fi return 0 } @@ -6769,28 +6973,28 @@ install_arch_linux_git() { install_arch_linux_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 # 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 # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue if [ -f /usr/bin/systemctl ]; then # Using systemd - /usr/bin/systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || ( - /usr/bin/systemctl preset salt-$fname.service > /dev/null 2>&1 && - /usr/bin/systemctl enable salt-$fname.service > /dev/null 2>&1 + /usr/bin/systemctl is-enabled "salt-$fname.service" > /dev/null 2>&1 || ( + /usr/bin/systemctl preset "salt-$fname.service" > /dev/null 2>&1 && + /usr/bin/systemctl enable "salt-$fname.service" > /dev/null 2>&1 ) sleep 1 /usr/bin/systemctl daemon-reload @@ -6804,11 +7008,11 @@ install_arch_linux_post() { install_arch_linux_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -6821,11 +7025,11 @@ install_arch_linux_git_post() { __copyfile "${_SERVICE_DIR}/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service" # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - /usr/bin/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( - /usr/bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && - /usr/bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 + /usr/bin/systemctl is-enabled "salt-${fname}.service" > /dev/null 2>&1 || ( + /usr/bin/systemctl preset "salt-${fname}.service" > /dev/null 2>&1 && + /usr/bin/systemctl enable "salt-${fname}.service" > /dev/null 2>&1 ) sleep 1 /usr/bin/systemctl daemon-reload @@ -6834,34 +7038,34 @@ install_arch_linux_git_post() { # SysV init!? __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname" "/etc/rc.d/init.d/salt-$fname" - chmod +x /etc/rc.d/init.d/salt-$fname + chmod +x "/etc/rc.d/init.d/salt-$fname" done } install_arch_linux_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 - /usr/bin/systemctl start salt-$fname.service && continue + /usr/bin/systemctl stop "salt-$fname.service" > /dev/null 2>&1 + /usr/bin/systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi fi - /etc/rc.d/salt-$fname stop > /dev/null 2>&1 - /etc/rc.d/salt-$fname start + "/etc/rc.d/salt-$fname" stop > /dev/null 2>&1 + "/etc/rc.d/salt-$fname" start done } @@ -6873,14 +7077,14 @@ install_arch_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 done return 0 @@ -6921,7 +7125,7 @@ __install_saltstack_photon_onedir_repository() { REPO_FILE="/etc/yum.repos.d/salt.repo" - if [ ! -s "$REPO_FILE" ] || [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then + if [ ! -s "$REPO_FILE" ] || [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; then FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/photon/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/${ONEDIR_REV}" if [ "${ONEDIR_REV}" = "nightly" ] ; then FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/photon/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/" @@ -6943,7 +7147,7 @@ __install_saltstack_photon_onedir_repository() { } install_photon_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then tdnf -y update || return 1 fi @@ -6964,7 +7168,7 @@ install_photon_deps() { fi # shellcheck disable=SC2086 - __tdnf_install_noinput ${__PACKAGES} ${_EXTRA_PACKAGES} || return 1 + __tdnf_install_noinput "${__PACKAGES}" "${_EXTRA_PACKAGES}" || return 1 return 0 } @@ -6972,14 +7176,14 @@ install_photon_deps() { install_photon_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload done @@ -7009,12 +7213,12 @@ install_photon_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then __PACKAGES="${__PACKAGES} ca-certificates" fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud python${PY_PKG_VER}-netaddr" fi @@ -7045,7 +7249,7 @@ install_photon_git_deps() { else __PACKAGES="python${PY_PKG_VER}-devel python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools gcc glibc-devel linux-devel.x86_64" # shellcheck disable=SC2086 - __tdnf_install_noinput ${__PACKAGES} || return 1 + __tdnf_install_noinput "${__PACKAGES}" || return 1 fi if [ "${DISTRO_MAJOR_VERSION}" -gt 3 ]; then @@ -7073,9 +7277,9 @@ install_photon_git() { fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - ${_PYEXE} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + ${_PYEXE} setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 else - ${_PYEXE} setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + ${_PYEXE} setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 fi return 0 } @@ -7083,11 +7287,11 @@ install_photon_git() { install_photon_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -7103,31 +7307,31 @@ install_photon_git_post() { #fi # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload done } install_photon_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 && continue + systemctl stop "salt-$fname" > /dev/null 2>&1 + systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi done @@ -7136,14 +7340,14 @@ install_photon_restart_daemons() { install_photon_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 done return 0 @@ -7151,7 +7355,7 @@ install_photon_check_services() { install_photon_onedir_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then tdnf -y update || return 1 fi @@ -7175,12 +7379,12 @@ install_photon_onedir_deps() { __PACKAGES="procps-ng" # shellcheck disable=SC2086 - __tdnf_install_noinput ${__PACKAGES} || return 1 + __tdnf_install_noinput "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __tdnf_install_noinput ${_EXTRA_PACKAGES} || return 1 + __tdnf_install_noinput "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -7189,31 +7393,31 @@ install_photon_onedir_deps() { install_photon_onedir() { - STABLE_REV=$ONEDIR_REV + STABLE_REV="$ONEDIR_REV" __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ];then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ];then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __tdnf_install_noinput ${__PACKAGES} || return 1 + __tdnf_install_noinput "${__PACKAGES}" || return 1 return 0 } install_photon_onedir_post() { - STABLE_REV=$ONEDIR_REV + STABLE_REV="$ONEDIR_REV" install_photon_stable_post || return 1 return 0 @@ -7231,7 +7435,7 @@ install_photon_onedir_post() { # Using a separate conf step to head for idempotent install... __configure_freebsd_pkg_details() { _SALT_ETC_DIR="/usr/local/etc/salt" - _PKI_DIR=${_SALT_ETC_DIR}/pki + _PKI_DIR="${_SALT_ETC_DIR}/pki" _POST_NEON_PIP_INSTALL_ARGS="--prefix=/usr/local" } @@ -7248,11 +7452,11 @@ install_freebsd_git_deps() { fi __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then SALT_DEPENDENCIES=$(/usr/local/sbin/pkg rquery %dn py39-salt) # shellcheck disable=SC2086 - /usr/local/sbin/pkg install -y ${SALT_DEPENDENCIES} python || return 1 + /usr/local/sbin/pkg install -y "${SALT_DEPENDENCIES}" python || return 1 /usr/local/sbin/pkg install -y py39-requests || return 1 /usr/local/sbin/pkg install -y py39-tornado4 || return 1 @@ -7266,11 +7470,11 @@ install_freebsd_git_deps() { for file in doc/man/salt-key.1 doc/man/salt-cp.1 doc/man/salt-minion.1 \ doc/man/salt-syndic.1 doc/man/salt-master.1 doc/man/salt-run.1 \ doc/man/salt.7 doc/man/salt.1 doc/man/salt-call.1; do - [ ! -f $file ] && continue + [ ! -f "$file" ] && continue echodebug "Patching ${file}" sed -in -e "s|/etc/salt|${_SALT_ETC_DIR}|" \ -e "s|/srv/salt|${_SALT_ETC_DIR}/states|" \ - -e "s|/srv/pillar|${_SALT_ETC_DIR}/pillar|" ${file} + -e "s|/srv/pillar|${_SALT_ETC_DIR}/pillar|" "${file}" done if [ ! -f salt/syspaths.py ]; then # We still can't provide the system paths, salt 0.16.x @@ -7280,11 +7484,11 @@ install_freebsd_git_deps() { for file in conf/minion conf/master salt/config.py salt/client.py \ salt/modules/mysql.py salt/utils/parsers.py salt/modules/tls.py \ salt/modules/postgres.py salt/utils/migrations.py; do - [ ! -f $file ] && continue + [ ! -f "$file" ] && continue echodebug "Patching ${file}" sed -in -e "s|/etc/salt|${_SALT_ETC_DIR}|" \ -e "s|/srv/salt|${_SALT_ETC_DIR}/states|" \ - -e "s|/srv/pillar|${_SALT_ETC_DIR}/pillar|" ${file} + -e "s|/srv/pillar|${_SALT_ETC_DIR}/pillar|" "${file}" done fi echodebug "Finished patching" @@ -7315,13 +7519,13 @@ install_freebsd_git() { __PYTHON_PATH=$(readlink -f "$(command -v python3)") __ESCAPED_PYTHON_PATH=$(echo "${__PYTHON_PATH}" | sed 's/\//\\\//g') - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${__PYTHON_PATH}" || return 1 for script in salt_api salt_master salt_minion salt_proxy salt_syndic; do __fetch_url "/usr/local/etc/rc.d/${script}" "https://raw.githubusercontent.com/freebsd/freebsd-ports/master/sysutils/py-salt/files/${script}.in" || return 1 - sed -i '' 's/%%PREFIX%%/\/usr\/local/g' /usr/local/etc/rc.d/${script} - sed -i '' "s/%%PYTHON_CMD%%/${__ESCAPED_PYTHON_PATH}/g" /usr/local/etc/rc.d/${script} - chmod +x /usr/local/etc/rc.d/${script} || return 1 + sed -i '' 's/%%PREFIX%%/\/usr\/local/g' "/usr/local/etc/rc.d/${script}" + sed -i '' "s/%%PYTHON_CMD%%/${__ESCAPED_PYTHON_PATH}/g" "/usr/local/etc/rc.d/${script}" + chmod +x "/usr/local/etc/rc.d/${script}" || return 1 done return 0 @@ -7330,7 +7534,7 @@ install_freebsd_git() { # Install from git if [ ! -f salt/syspaths.py ]; then # We still can't provide the system paths, salt 0.16.x - ${__PYTHON_PATH} setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + ${__PYTHON_PATH} setup.py "${SETUP_PY_INSTALL_ARGS}" install || return 1 else ${__PYTHON_PATH} setup.py \ --salt-root-dir=/ \ @@ -7343,15 +7547,15 @@ install_freebsd_git() { --salt-base-master-roots-dir="${_SALT_ETC_DIR}/salt-master" \ --salt-logs-dir=/var/log/salt \ --salt-pidfile-dir=/var/run \ - ${SETUP_PY_INSTALL_ARGS} install \ + "${SETUP_PY_INSTALL_ARGS}" install \ || return 1 fi for script in salt_api salt_master salt_minion salt_proxy salt_syndic; do __fetch_url "/usr/local/etc/rc.d/${script}" "https://raw.githubusercontent.com/freebsd/freebsd-ports/master/sysutils/py-salt/files/${script}.in" || return 1 - sed -i '' 's/%%PREFIX%%/\/usr\/local/g' /usr/local/etc/rc.d/${script} - sed -i '' "s/%%PYTHON_CMD%%/${__ESCAPED_PYTHON_PATH}/g" /usr/local/etc/rc.d/${script} - chmod +x /usr/local/etc/rc.d/${script} || return 1 + sed -i '' 's/%%PREFIX%%/\/usr\/local/g' "/usr/local/etc/rc.d/${script}" + sed -i '' "s/%%PYTHON_CMD%%/${__ESCAPED_PYTHON_PATH}/g" "/usr/local/etc/rc.d/${script}" + chmod +x "/usr/local/etc/rc.d/${script}" || return 1 done # And we're good to go @@ -7361,16 +7565,16 @@ install_freebsd_git() { install_freebsd_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 - [ $? -eq 1 ] && sysrc $enable_string + [ $? -eq 1 ] && sysrc "$enable_string" done } @@ -7381,19 +7585,19 @@ install_freebsd_git_post() { } install_freebsd_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - service salt_$fname stop > /dev/null 2>&1 - service salt_$fname start + service "salt_$fname" stop > /dev/null 2>&1 + service "salt_$fname" start done } @@ -7416,7 +7620,7 @@ install_freebsd_onedir() { # install_openbsd_deps() { - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ]; then OPENBSD_REPO='https://cdn.openbsd.org/pub/OpenBSD' echoinfo "setting package repository to $OPENBSD_REPO" echo "${OPENBSD_REPO}" >/etc/installurl || return 1 @@ -7425,7 +7629,7 @@ install_openbsd_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - pkg_add -I -v ${_EXTRA_PACKAGES} || return 1 + pkg_add -I -v "${_EXTRA_PACKAGES}" || return 1 fi return 0 } @@ -7438,7 +7642,7 @@ install_openbsd_git_deps() { fi __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then pkg_add -I -v py3-pip py3-setuptools fi @@ -7457,14 +7661,14 @@ install_openbsd_git() { # # Install from git # - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ ! -f salt/syspaths.py ]; then # We still can't provide the system paths, salt 0.16.x - /usr/local/bin/python2.7 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + /usr/local/bin/python2.7 setup.py "${SETUP_PY_INSTALL_ARGS}" install || return 1 fi return 0 } @@ -7476,12 +7680,12 @@ install_openbsd_stable() { install_openbsd_post() { for fname in api master minion syndic; do - [ $fname = "api" ] && 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 + [ "$fname" = "api" ] && 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 - rcctl enable salt_$fname + rcctl enable "salt_$fname" done return 0 @@ -7490,15 +7694,15 @@ install_openbsd_post() { install_openbsd_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && continue - if [ -f /etc/rc.d/salt_${fname} ]; then - __check_services_openbsd salt_${fname} || return 1 + if [ -f "/etc/rc.d/salt_${fname}" ]; then + __check_services_openbsd "salt_${fname}" || return 1 fi done @@ -7506,18 +7710,18 @@ install_openbsd_check_services() { } install_openbsd_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - rcctl restart salt_${fname} + rcctl restart "salt_${fname}" done return 0 @@ -7545,9 +7749,9 @@ install_smartos_deps() { pkgin -y install "${smartos_deps}" || return 1 # Set _SALT_ETC_DIR to SmartOS default if they didn't specify - _SALT_ETC_DIR=${BS_SALT_ETC_DIR:-/opt/local/etc/salt} + _SALT_ETC_DIR="${BS_SALT_ETC_DIR:-/opt/local/etc/salt}" # We also need to redefine the PKI directory - _PKI_DIR=${_SALT_ETC_DIR}/pki + _PKI_DIR="${_SALT_ETC_DIR}/pki" # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -7561,21 +7765,21 @@ install_smartos_deps() { curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/minion" -L \ https://raw.githubusercontent.com/saltstack/salt/master/conf/minion || return 1 fi - if [ ! -f "$_SALT_ETC_DIR/master" ] && [ ! -f $_TEMP_CONFIG_DIR/master ]; then + if [ ! -f "$_SALT_ETC_DIR/master" ] && [ ! -f "$_TEMP_CONFIG_DIR/master" ]; then # shellcheck disable=SC2086 curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/master" -L \ https://raw.githubusercontent.com/saltstack/salt/master/conf/master || return 1 fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then pkgin -y install py27-apache-libcloud || return 1 fi if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - pkgin -y install ${_EXTRA_PACKAGES} || return 1 + pkgin -y install "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -7590,7 +7794,7 @@ install_smartos_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # Install whichever tornado is in the requirements file @@ -7638,14 +7842,14 @@ install_smartos_stable() { install_smartos_git() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi # Use setuptools in order to also install dependencies # lets force our config path on the setup for now, since salt/syspaths.py only got fixed in 2015.5.0 - USE_SETUPTOOLS=1 /opt/local/bin/python setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + USE_SETUPTOOLS=1 /opt/local/bin/python setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install || return 1 return 0 } @@ -7655,17 +7859,17 @@ install_smartos_post() { # Install manifest files if needed. for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 if [ ! -f "$_TEMP_CONFIG_DIR/salt-$fname.xml" ]; then # shellcheck disable=SC2086 - curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/salt-$fname.xml" -L \ + curl "$_CURL_ARGS" -s -o "$_TEMP_CONFIG_DIR/salt-$fname.xml" -L \ "https://raw.githubusercontent.com/saltstack/salt/master/pkg/smartos/salt-$fname.xml" fi svccfg import "$_TEMP_CONFIG_DIR/salt-$fname.xml" @@ -7689,17 +7893,17 @@ install_smartos_git_post() { # Install manifest files if needed. for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue svcs "network/salt-$fname" > /dev/null 2>&1 if [ $? -eq 1 ]; then svccfg import "${_SALT_GIT_CHECKOUT_DIR}/pkg/smartos/salt-$fname.xml" if [ "${VIRTUAL_TYPE}" = "global" ]; then - if [ ! -d $smf_dir ]; then + if [ ! -d "$smf_dir" ]; then mkdir -p "$smf_dir" fi if [ ! -f "$smf_dir/salt-$fname.xml" ]; then @@ -7713,20 +7917,20 @@ install_smartos_git_post() { } install_smartos_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 - svcadm enable salt-$fname + svcadm disable "salt-$fname" > /dev/null 2>&1 + svcadm enable "salt-$fname" done return 0 @@ -7785,9 +7989,9 @@ __version_lte() { fi if [ "$(${_PY_EXE} -c 'import sys; V1=tuple([int(i) for i in sys.argv[1].split(".")]); V2=tuple([int(i) for i in sys.argv[2].split(".")]); print(V1<=V2)' "$1" "$2")" = "True" ]; then - __ZYPPER_REQUIRES_REPLACE_FILES=${BS_TRUE} + __ZYPPER_REQUIRES_REPLACE_FILES="${BS_TRUE}" else - __ZYPPER_REQUIRES_REPLACE_FILES=${BS_FALSE} + __ZYPPER_REQUIRES_REPLACE_FILES="${BS_FALSE}" fi } @@ -7824,7 +8028,7 @@ __zypper_install() { __opensuse_prep_install() { # DRY function for common installation preparatory steps for SUSE - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ]; then # Is the repository already known __set_suse_pkg_repo # Check zypper repos and refresh if necessary @@ -7840,7 +8044,7 @@ __opensuse_prep_install() { return 1 fi - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then __zypper --gpg-auto-import-keys update || return 1 fi } @@ -7859,19 +8063,19 @@ install_opensuse_stable_deps() { __PACKAGES="python-PyYAML python-requests python-zypp" # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __zypper_install ${_EXTRA_PACKAGES} || return 1 + __zypper_install "${_EXTRA_PACKAGES}" || return 1 fi return 0 } install_opensuse_git_deps() { - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ] && ! __check_command_exists update-ca-certificates; then + if [ "$_INSECURE_DL" -eq "$BS_FALSE" ] && [ "${_SALT_REPO_URL%%://*}" = "https" ] && ! __check_command_exists update-ca-certificates; then __zypper_install ca-certificates || return 1 fi @@ -7883,7 +8087,7 @@ install_opensuse_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then __zypper_install patch || return 1 __PACKAGES="libzmq5 python-Jinja2 python-m2crypto python-msgpack-python python-pycrypto python-pyzmq python-xml python-futures" @@ -7896,7 +8100,7 @@ install_opensuse_git_deps() { fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python-apache-libcloud" fi # Check for Tumbleweed @@ -7907,7 +8111,7 @@ install_opensuse_git_deps() { fi # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -7925,32 +8129,32 @@ install_opensuse_onedir_deps() { install_opensuse_stable() { __PACKAGES="" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ];then __PACKAGES="${__PACKAGES} salt-cloud" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-master" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi # shellcheck disable=SC2086 - __zypper_install $__PACKAGES || return 1 + __zypper_install "$__PACKAGES" || return 1 return 0 } install_opensuse_git() { - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi - python setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + python setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 return 0 } @@ -7961,22 +8165,22 @@ install_opensuse_onedir() { install_opensuse_stable_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if [ -f /bin/systemctl ] || [ -f /usr/bin/systemctl ]; then - systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) + systemctl is-enabled "salt-$fname.service" || (systemctl preset "salt-$fname.service" && systemctl enable "salt-$fname.service") sleep 1 systemctl daemon-reload continue fi - /sbin/chkconfig --add salt-$fname - /sbin/chkconfig salt-$fname on + /sbin/chkconfig --add "salt-$fname" + /sbin/chkconfig "salt-$fname" on done return 0 @@ -7985,21 +8189,21 @@ install_opensuse_stable_post() { install_opensuse_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if command -v systemctl; then - use_usr_lib=$BS_FALSE + use_usr_lib="$BS_FALSE" if [ "${DISTRO_MAJOR_VERSION}" -ge 15 ]; then - use_usr_lib=$BS_TRUE + use_usr_lib="$BS_TRUE" fi if [ "${DISTRO_MAJOR_VERSION}" -eq 12 ] && [ -d "/usr/lib/systemd/" ]; then - use_usr_lib=$BS_TRUE + use_usr_lib="$BS_TRUE" fi # Account for new path for services files in later releases @@ -8009,7 +8213,7 @@ install_opensuse_git_post() { _SERVICE_DIR="${_SALT_GIT_CHECKOUT_DIR}/pkg/" fi - if [ "${use_usr_lib}" -eq $BS_TRUE ]; then + if [ "${use_usr_lib}" -eq "$BS_TRUE" ]; then __copyfile "${_SERVICE_DIR}/salt-${fname}.service" "/usr/lib/systemd/system/salt-${fname}.service" else __copyfile "${_SERVICE_DIR}/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service" @@ -8019,7 +8223,7 @@ install_opensuse_git_post() { fi __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname" "/etc/init.d/salt-$fname" - chmod +x /etc/init.d/salt-$fname + chmod +x "/etc/init.d/salt-$fname" done install_opensuse_stable_post || return 1 @@ -8032,29 +8236,29 @@ install_opensuse_onedir_post() { } install_opensuse_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 - systemctl start salt-$fname.service && continue + systemctl stop "salt-$fname" > /dev/null 2>&1 + systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi fi - service salt-$fname stop > /dev/null 2>&1 - service salt-$fname start + service "salt-$fname" stop > /dev/null 2>&1 + service "salt-$fname" start done } @@ -8066,14 +8270,14 @@ install_opensuse_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_systemd salt-$fname > /dev/null 2>&1 || __check_services_systemd salt-$fname.service > /dev/null 2>&1 || return 1 + __check_services_systemd "salt-$fname" > /dev/null 2>&1 || __check_services_systemd "salt-$fname.service" > /dev/null 2>&1 || return 1 done return 0 @@ -8105,12 +8309,12 @@ install_opensuse_15_stable_deps() { __PACKAGES="python${PY_PKG_VER}-PyYAML python${PY_PKG_VER}-requests" # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __zypper_install ${_EXTRA_PACKAGES} || return 1 + __zypper_install "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -8133,7 +8337,7 @@ install_opensuse_15_git_deps() { __PACKAGES="python${PY_PKG_VER}-xml" - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then # Py3 is the default bootstrap install for Leap 15 # However, git installs might specify "-x python2" @@ -8153,7 +8357,7 @@ install_opensuse_15_git_deps() { fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-apache-libcloud" fi else @@ -8161,7 +8365,7 @@ install_opensuse_15_git_deps() { fi # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -8176,17 +8380,17 @@ install_opensuse_15_git() { # Py3 is the default bootstrap install for Leap 15 if [ -n "$_PY_EXE" ]; then - _PYEXE=${_PY_EXE} + _PYEXE="${_PY_EXE}" else _PYEXE=python3 fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi - ${_PYEXE} setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 + ${_PYEXE} setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/usr || return 1 return 0 } @@ -8284,12 +8488,12 @@ install_suse_12_stable_deps() { # Salt needs python-zypp installed in order to use the zypper module __PACKAGES="python-PyYAML python-requests python-zypp" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python-apache-libcloud" fi # shellcheck disable=SC2086,SC2090 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # SLES 11 SP3 ships with both python-M2Crypto-0.22.* and python-m2crypto-0.21 and we will be asked which # we want to install, even with --non-interactive. @@ -8299,7 +8503,7 @@ install_suse_12_stable_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __zypper_install ${_EXTRA_PACKAGES} || return 1 + __zypper_install "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -8327,12 +8531,12 @@ install_suse_12_git_deps() { fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python-apache-libcloud" fi # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -8400,7 +8604,7 @@ install_suse_11_stable_deps() { __PACKAGES="python-PyYAML" # shellcheck disable=SC2086,SC2090 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # SLES 11 SP3 ships with both python-M2Crypto-0.22.* and python-m2crypto-0.21 and we will be asked which # we want to install, even with --non-interactive. @@ -8410,7 +8614,7 @@ install_suse_11_stable_deps() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __zypper_install ${_EXTRA_PACKAGES} || return 1 + __zypper_install "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -8438,12 +8642,12 @@ install_suse_11_git_deps() { fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then __PACKAGES="${__PACKAGES} python-apache-libcloud" fi # shellcheck disable=SC2086 - __zypper_install ${__PACKAGES} || return 1 + __zypper_install "${__PACKAGES}" || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -8514,14 +8718,14 @@ install_suse_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 done return 0 @@ -8555,14 +8759,14 @@ __autounmask() { __emerge() { EMERGE_FLAGS='-q' - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then EMERGE_FLAGS='-v' fi # Do not re-emerge packages that are already installed EMERGE_FLAGS="${EMERGE_FLAGS} --noreplace" - if [ "$_GENTOO_USE_BINHOST" -eq $BS_TRUE ]; then + if [ "$_GENTOO_USE_BINHOST" -eq "$BS_TRUE" ]; then EMERGE_FLAGS="${EMERGE_FLAGS} --getbinpkg" fi @@ -8571,7 +8775,7 @@ __emerge() { } __gentoo_pre_dep() { - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then if __check_command_exists eix; then eix-sync else @@ -8605,9 +8809,9 @@ __gentoo_post_dep() { if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - __autounmask ${_EXTRA_PACKAGES} || return 1 + __autounmask "${_EXTRA_PACKAGES}" || return 1 # shellcheck disable=SC2086 - __emerge ${_EXTRA_PACKAGES} || return 1 + __emerge "${_EXTRA_PACKAGES}" || return 1 fi return 0 @@ -8617,20 +8821,20 @@ install_gentoo_deps() { __gentoo_pre_dep || return 1 # Make sure that the 'libcloud' use flag is set when Salt Cloud support is requested - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then SALT_USE_FILE='/etc/portage/package.use' if [ -d '/etc/portage/package.use' ]; then SALT_USE_FILE='/etc/portage/package.use/salt' fi - SALT_USE_FLAGS="$(grep -E '^[<>=~]*app-admin/salt.*' ${SALT_USE_FILE} 2>/dev/null)" + SALT_USE_FLAGS="$(grep -E '^[<>=~]*app-admin/salt.*' "${SALT_USE_FILE}" 2>/dev/null)" SALT_USE_FLAG_LIBCLOUD="$(echo "${SALT_USE_FLAGS}" | grep ' libcloud' 2>/dev/null)" # Set the libcloud use flag, if it is not set yet if [ -z "${SALT_USE_FLAGS}" ]; then - echo "app-admin/salt libcloud" >> ${SALT_USE_FILE} + echo "app-admin/salt libcloud" >> "${SALT_USE_FILE}" elif [ -z "${SALT_USE_FLAG_LIBCLOUD}" ]; then - sed 's#^\([<>=~]*app-admin/salt[^ ]*\)\(.*\)#\1 libcloud\2#g' -i ${SALT_USE_FILE} + sed 's#^\([<>=~]*app-admin/salt[^ ]*\)\(.*\)#\1 libcloud\2#g' -i "${SALT_USE_FILE}" fi fi @@ -8651,7 +8855,7 @@ install_gentoo_git_deps() { fi # Salt <3000 does not automatically install dependencies. It has to be done manually. - if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then GENTOO_GIT_PACKAGES="${GENTOO_GIT_PACKAGES:-} sys-apps/pciutils dev-python/pyyaml @@ -8672,7 +8876,7 @@ install_gentoo_git_deps() { fi # Install libcloud when Salt Cloud support was requested - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then GENTOO_GIT_PACKAGES="${GENTOO_GIT_PACKAGES:-} dev-python/libcloud" fi @@ -8699,19 +8903,19 @@ install_gentoo_stable() { fi # shellcheck disable=SC2086 - __autounmask ${GENTOO_SALT_PACKAGE} || return 1 + __autounmask "${GENTOO_SALT_PACKAGE}" || return 1 # shellcheck disable=SC2086 - __emerge ${GENTOO_SALT_PACKAGE} || return 1 + __emerge "${GENTOO_SALT_PACKAGE}" || return 1 } install_gentoo_git() { - _PYEXE=${_PY_EXE} + _PYEXE="${_PY_EXE}" if [ "$_PY_EXE" = "python3" ] || [ -z "$_PY_EXE" ]; then if [ "${GIT_REV}" = "v3000" ]; then # Salt Neon does not support Python 3.8 and greater _PYEXE=python3.7 - elif [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then + elif [ "${_POST_NEON_INSTALL}" -eq "$BS_FALSE" ]; then # Tornado 4.3 ebuild supports only Python 3.6, use Python 3.6 as the default Python 3 interpreter _PYEXE=python3.6 else @@ -8719,44 +8923,44 @@ install_gentoo_git() { fi fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PYEXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + "${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install || return 1 else - "${_PYEXE}" setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + "${_PYEXE}" setup.py "${SETUP_PY_INSTALL_ARGS}" install || return 1 fi return 0 } install_gentoo_onedir() { - STABLE_REV=${ONEDIR_REV} + STABLE_REV="${ONEDIR_REV}" install_gentoo_stable || return 1 } install_gentoo_post() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue if __check_command_exists systemctl ; then - systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || ( - systemctl preset salt-$fname.service > /dev/null 2>&1 && - systemctl enable salt-$fname.service > /dev/null 2>&1 + systemctl is-enabled "salt-$fname.service" > /dev/null 2>&1 || ( + systemctl preset "salt-$fname.service" > /dev/null 2>&1 && + systemctl enable "salt-$fname.service" > /dev/null 2>&1 ) else # Salt minion cannot start in a docker container because the "net" service is not available - if [ $fname = "minion" ] && [ -f /.dockerenv ]; then - sed '/need net/d' -i /etc/init.d/salt-$fname + if [ "$fname" = "minion" ] && [ -f /.dockerenv ]; then + sed '/need net/d' -i "/etc/init.d/salt-$fname" fi rc-update add "salt-$fname" > /dev/null 2>&1 || return 1 @@ -8767,11 +8971,11 @@ install_gentoo_post() { install_gentoo_git_post() { for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] || ! __check_command_exists "salt-${fname}") && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue # Account for new path for services files in later releases if [ -f "${_SALT_GIT_CHECKOUT_DIR}/pkg/common/salt-${fname}.service" ]; then @@ -8784,11 +8988,11 @@ install_gentoo_git_post() { __copyfile "${_SERVICE_DIR}/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service" # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue - systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || ( - systemctl preset salt-$fname.service > /dev/null 2>&1 && - systemctl enable salt-$fname.service > /dev/null 2>&1 + systemctl is-enabled "salt-$fname.service" > /dev/null 2>&1 || ( + systemctl preset "salt-$fname.service" > /dev/null 2>&1 && + systemctl enable "salt-$fname.service" > /dev/null 2>&1 ) else cat <<_eof > "/etc/init.d/salt-${fname}" @@ -8807,7 +9011,7 @@ depend() { use net logger } _eof - chmod +x /etc/init.d/salt-$fname + chmod +x "/etc/init.d/salt-$fname" cat <<_eof > "/etc/conf.d/salt-${fname}" # /etc/conf.d/salt-${fname}: config file for /etc/init.d/salt-master @@ -8818,7 +9022,7 @@ SALT_OPTS="--log-level=warning" _eof # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue rc-update add "salt-$fname" > /dev/null 2>&1 || return 1 fi @@ -8832,7 +9036,7 @@ install_gentoo_onedir_post() { } install_gentoo_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return # Ensure upstart configs / systemd units are loaded if __check_command_exists systemctl ; then @@ -8841,25 +9045,25 @@ install_gentoo_restart_daemons() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 __check_command_exists systemctl ; then - systemctl stop salt-$fname > /dev/null 2>&1 - systemctl start salt-$fname.service && continue + systemctl stop "salt-$fname" > /dev/null 2>&1 + systemctl start "salt-$fname.service" && continue echodebug "Failed to start salt-$fname using systemd" - if [ "$_ECHO_DEBUG" -eq $BS_TRUE ]; then - systemctl status salt-$fname.service + if [ "$_ECHO_DEBUG" -eq "$BS_TRUE" ]; then + systemctl status "salt-$fname.service" journalctl -xe fi else # Disable stdin to fix shell session hang on killing tee pipe - rc-service salt-$fname stop < /dev/null > /dev/null 2>&1 - rc-service salt-$fname start < /dev/null || return 1 + rc-service "salt-$fname" stop < /dev/null > /dev/null 2>&1 + rc-service "salt-$fname" start < /dev/null || return 1 fi done @@ -8869,17 +9073,17 @@ install_gentoo_restart_daemons() { install_gentoo_check_services() { for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 __check_command_exists systemctl ; then - __check_services_systemd salt-$fname || return 1 + __check_services_systemd "salt-$fname" || return 1 else - __check_services_openrc salt-$fname || return 1 + __check_services_openrc "salt-$fname" || return 1 fi done @@ -8895,7 +9099,7 @@ install_gentoo_check_services() { # VoidLinux Install Functions # install_voidlinux_stable_deps() { - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + if [ "$_UPGRADE_SYS" -eq "$BS_TRUE" ]; then xbps-install -Suy || return 1 fi @@ -8914,54 +9118,54 @@ install_voidlinux_stable() { install_voidlinux_stable_post() { for fname in master minion syndic; do - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - ln -s /etc/sv/salt-$fname /var/service/. + ln -s "/etc/sv/salt-$fname" /var/service/. done } install_voidlinux_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return for fname in master minion syndic; do - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - sv restart salt-$fname + sv restart "salt-$fname" done } install_voidlinux_check_services() { for fname in master minion syndic; do - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq "$BS_FALSE" ] && continue + [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq "$BS_FALSE" ] && continue - [ -e /var/service/salt-$fname ] || return 1 + [ -e "/var/service/salt-$fname" ] || return 1 done return 0 } daemons_running_voidlinux() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return 0 FAILED_DAEMONS=0 for fname in master minion syndic; do - [ $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 [ "$(sv status salt-$fname | grep run)" = "" ]; then + if [ "$(sv status "salt-$fname" | grep run)" = "" ]; then echoerror "salt-$fname was not found running" FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) fi done - return $FAILED_DAEMONS + return "$FAILED_DAEMONS" } # # Ended VoidLinux Install Functions @@ -9050,13 +9254,13 @@ install_macosx_git_deps() { if ! echo "$PATH" | grep -q /usr/local/bin; then echowarn "/usr/local/bin was not found in \$PATH. Adding it for the duration of the script execution." - export PATH=/usr/local/bin:$PATH + export PATH="/usr/local/bin:$PATH" fi __fetch_url "/tmp/get-pip.py" "https://bootstrap.pypa.io/get-pip.py" || return 1 if [ -n "$_PY_EXE" ]; then - _PYEXE=${_PY_EXE} + _PYEXE="${_PY_EXE}" else _PYEXE=python2.7 fi @@ -9066,7 +9270,7 @@ install_macosx_git_deps() { __git_clone_and_checkout || return 1 - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then return 0 fi @@ -9104,20 +9308,20 @@ install_macosx_onedir() { install_macosx_git() { if [ -n "$_PY_EXE" ]; then - _PYEXE=${_PY_EXE} + _PYEXE="${_PY_EXE}" else _PYEXE=python2.7 fi - if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then + if [ "${_POST_NEON_INSTALL}" -eq "$BS_TRUE" ]; then __install_salt_from_repo_post_neon "${_PY_EXE}" || return 1 return 0 fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then - $_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/opt/salt || return 1 + $_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" "${SETUP_PY_INSTALL_ARGS}" install --prefix=/opt/salt || return 1 else - $_PYEXE setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/opt/salt || return 1 + $_PYEXE setup.py "${SETUP_PY_INSTALL_ARGS}" install --prefix=/opt/salt || return 1 fi return 0 @@ -9149,14 +9353,14 @@ install_macosx_git_post() { } install_macosx_restart_daemons() { - [ $_START_DAEMONS -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ]; then /bin/launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1 /bin/launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1 fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ]; then /bin/launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.master.plist || return 1 /bin/launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.master.plist || return 1 fi @@ -9177,13 +9381,13 @@ config_salt() { # If the configuration directory is not passed, return [ "$_TEMP_CONFIG_DIR" = "null" ] && return - if [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then + if [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ]; then echowarn "Passing -C (config only) option implies -F (forced overwrite)." - if [ "$_FORCE_OVERWRITE" -ne $BS_TRUE ]; then + if [ "$_FORCE_OVERWRITE" -ne "$BS_TRUE" ]; then echowarn "Overwriting configs in 11 seconds!" sleep 11 - _FORCE_OVERWRITE=$BS_TRUE + _FORCE_OVERWRITE="$BS_TRUE" fi fi @@ -9193,9 +9397,9 @@ config_salt() { # If -C or -F was passed, we don't need a .bak file for the config we're updating # This is used in the custom master/minion config file checks below - CREATE_BAK=$BS_TRUE - if [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then - CREATE_BAK=$BS_FALSE + CREATE_BAK="$BS_TRUE" + if [ "$_FORCE_OVERWRITE" -eq "$BS_TRUE" ]; then + CREATE_BAK="$BS_FALSE" fi CONFIGURED_ANYTHING=$BS_FALSE @@ -9204,11 +9408,11 @@ config_salt() { if [ -f "$_TEMP_CONFIG_DIR/grains" ]; then echodebug "Moving provided grains file from $_TEMP_CONFIG_DIR/grains to $_SALT_ETC_DIR/grains" __movefile "$_TEMP_CONFIG_DIR/grains" "$_SALT_ETC_DIR/grains" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ] || \ - [ "$_CONFIG_ONLY" -eq $BS_TRUE ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then + if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ] || \ + [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then # Create the PKI directory [ -d "$_PKI_DIR/minion" ] || (mkdir -p "$_PKI_DIR/minion" && chmod 700 "$_PKI_DIR/minion") || return 1 @@ -9217,51 +9421,51 @@ config_salt() { # Check if a minion config file already exists and move to .bak if needed if [ -f "$_SALT_ETC_DIR/minion" ] && [ "$CREATE_BAK" -eq "$BS_TRUE" ]; then - __movefile "$_SALT_ETC_DIR/minion" "$_SALT_ETC_DIR/minion.bak" $BS_TRUE || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + __movefile "$_SALT_ETC_DIR/minion" "$_SALT_ETC_DIR/minion.bak" "$BS_TRUE" || return 1 + CONFIGURED_ANYTHING="$BS_TRUE" fi # Overwrite/create the config file with the yaml string __overwriteconfig "$_SALT_ETC_DIR/minion" "$_CUSTOM_MINION_CONFIG" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" # Copy the minions configuration if found # Explicitly check for custom master config to avoid moving the minion config elif [ -f "$_TEMP_CONFIG_DIR/minion" ] && [ "$_CUSTOM_MASTER_CONFIG" = "null" ]; then __movefile "$_TEMP_CONFIG_DIR/minion" "$_SALT_ETC_DIR" "$_FORCE_OVERWRITE" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + 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/" "$_FORCE_OVERWRITE" || return 1 chmod 400 "$_PKI_DIR/minion/minion.pem" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi if [ -f "$_TEMP_CONFIG_DIR/minion.pub" ]; then __movefile "$_TEMP_CONFIG_DIR/minion.pub" "$_PKI_DIR/minion/" "$_FORCE_OVERWRITE" || return 1 chmod 664 "$_PKI_DIR/minion/minion.pub" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi # For multi-master-pki, copy the master_sign public key if found if [ -f "$_TEMP_CONFIG_DIR/master_sign.pub" ]; then __movefile "$_TEMP_CONFIG_DIR/master_sign.pub" "$_PKI_DIR/minion/" || return 1 chmod 664 "$_PKI_DIR/minion/master_sign.pub" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi fi # only (re)place master or syndic configs if -M (install master) or -S # (install syndic) specified - OVERWRITE_MASTER_CONFIGS=$BS_FALSE - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then - OVERWRITE_MASTER_CONFIGS=$BS_TRUE + OVERWRITE_MASTER_CONFIGS="$BS_FALSE" + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ] && [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ]; then + OVERWRITE_MASTER_CONFIGS="$BS_TRUE" fi - if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then - OVERWRITE_MASTER_CONFIGS=$BS_TRUE + if [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ] && [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ]; then + OVERWRITE_MASTER_CONFIGS="$BS_TRUE" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ] || [ "$OVERWRITE_MASTER_CONFIGS" -eq $BS_TRUE ] || [ "$_CUSTOM_MASTER_CONFIG" != "null" ]; then + if [ "$_INSTALL_MASTER" -eq "$BS_TRUE" ] || [ "$_INSTALL_SYNDIC" -eq "$BS_TRUE" ] || [ "$OVERWRITE_MASTER_CONFIGS" -eq "$BS_TRUE" ] || [ "$_CUSTOM_MASTER_CONFIG" != "null" ]; then # Create the PKI directory [ -d "$_PKI_DIR/master" ] || (mkdir -p "$_PKI_DIR/master" && chmod 700 "$_PKI_DIR/master") || return 1 @@ -9270,34 +9474,34 @@ config_salt() { # Check if a master config file already exists and move to .bak if needed if [ -f "$_SALT_ETC_DIR/master" ] && [ "$CREATE_BAK" -eq "$BS_TRUE" ]; then - __movefile "$_SALT_ETC_DIR/master" "$_SALT_ETC_DIR/master.bak" $BS_TRUE || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + __movefile "$_SALT_ETC_DIR/master" "$_SALT_ETC_DIR/master.bak" "$BS_TRUE" || return 1 + CONFIGURED_ANYTHING="$BS_TRUE" fi # Overwrite/create the config file with the yaml string __overwriteconfig "$_SALT_ETC_DIR/master" "$_CUSTOM_MASTER_CONFIG" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" # Copy the masters configuration if found elif [ -f "$_TEMP_CONFIG_DIR/master" ]; then __movefile "$_TEMP_CONFIG_DIR/master" "$_SALT_ETC_DIR" || return 1 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi - # Copy the master's keys if found + # Copy the masters 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 - CONFIGURED_ANYTHING=$BS_TRUE + 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 - CONFIGURED_ANYTHING=$BS_TRUE + CONFIGURED_ANYTHING="$BS_TRUE" fi fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + if [ "$_INSTALL_CLOUD" -eq "$BS_TRUE" ]; then # Recursively copy salt-cloud configs with overwriting if necessary for file in "$_TEMP_CONFIG_DIR"/cloud*; do if [ -f "$file" ]; then @@ -9314,7 +9518,7 @@ config_salt() { done 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 @@ -9366,17 +9570,17 @@ preseed_master() { # This function checks if all of the installed daemons are running or not. # daemons_running_onedir() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return 0 FAILED_DAEMONS=0 for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 "/opt/saltstack/salt/run/run" ]; then salt_path="/opt/saltstack/salt/run/run ${fname}" @@ -9390,7 +9594,7 @@ daemons_running_onedir() { fi done - return $FAILED_DAEMONS + return "$FAILED_DAEMONS" } # @@ -9403,31 +9607,31 @@ daemons_running_onedir() { # This function checks if all of the installed daemons are running or not. # daemons_running() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 + [ "$_START_DAEMONS" -eq "$BS_FALSE" ] && return 0 FAILED_DAEMONS=0 for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # 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 - if [ "$(svcs -Ho STA salt-$fname)" != "ON" ]; then + if [ "$(svcs -Ho STA "salt-$fname")" != "ON" ]; then echoerror "salt-$fname was not found running" FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) fi - elif [ "$(ps wwwaux | grep -v grep | grep salt-$fname)" = "" ]; then + elif [ "$(ps wwwaux | grep -v grep | grep "salt-$fname")" = "" ]; then echoerror "salt-$fname was not found running" FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) fi done - return $FAILED_DAEMONS + return "${FAILED_DAEMONS}" } # # Ended daemons running check function @@ -9440,7 +9644,7 @@ daemons_running() { # Let's get the dependencies install function DEP_FUNC_NAMES="" -if [ ${_NO_DEPS} -eq $BS_FALSE ]; then +if [ ${_NO_DEPS} -eq "$BS_FALSE" ]; then DEP_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_deps" DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_deps" DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_deps" @@ -9450,9 +9654,9 @@ if [ ${_NO_DEPS} -eq $BS_FALSE ]; then fi DEPS_INSTALL_FUNC="null" -for FUNC_NAME in $(__strip_duplicates "$DEP_FUNC_NAMES"); do - if __function_defined "$FUNC_NAME"; then - DEPS_INSTALL_FUNC="$FUNC_NAME" +for FUNC_NAME in $(__strip_duplicates "${DEP_FUNC_NAMES}"); do + if __function_defined "${FUNC_NAME}"; then + DEPS_INSTALL_FUNC="${FUNC_NAME}" break fi done @@ -9460,17 +9664,17 @@ echodebug "DEPS_INSTALL_FUNC=${DEPS_INSTALL_FUNC}" # Let's get the Salt config function CONFIG_FUNC_NAMES="config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_${ITYPE}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_salt" -CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_${DISTRO_NAME_L}_${ITYPE}_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_${DISTRO_NAME_L}_salt" +CONFIG_FUNC_NAMES="${CONFIG_FUNC_NAMES} config_salt" CONFIG_SALT_FUNC="null" -for FUNC_NAME in $(__strip_duplicates "$CONFIG_FUNC_NAMES"); do - if __function_defined "$FUNC_NAME"; then - CONFIG_SALT_FUNC="$FUNC_NAME" +for FUNC_NAME in $(__strip_duplicates "${CONFIG_FUNC_NAMES}"); do + if __function_defined "${FUNC_NAME}"; then + CONFIG_SALT_FUNC="${FUNC_NAME}" break fi done @@ -9562,7 +9766,7 @@ for FUNC_NAME in $(__strip_duplicates "$DAEMONS_RUNNING_FUNC_NAMES"); do done echodebug "DAEMONS_RUNNING_FUNC=${DAEMONS_RUNNING_FUNC}" -# Let's get the check services function +# Lets get the check services function if [ ${_DISABLE_SALT_CHECKS} -eq $BS_FALSE ]; then CHECK_SERVICES_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_check_services" CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_check_services" @@ -9595,17 +9799,17 @@ fi # Install dependencies -if [ ${_NO_DEPS} -eq $BS_FALSE ] && [ $_CONFIG_ONLY -eq $BS_FALSE ]; then +if [ "${_NO_DEPS}" -eq "$BS_FALSE" ] && [ "$_CONFIG_ONLY" -eq "$BS_FALSE" ]; then # Only execute function is not in config mode only echoinfo "Running ${DEPS_INSTALL_FUNC}()" - if ! ${DEPS_INSTALL_FUNC}; then + if ! "${DEPS_INSTALL_FUNC}"; then echoerror "Failed to run ${DEPS_INSTALL_FUNC}()!!!" exit 1 fi fi -if [ "${ITYPE}" = "git" ] && [ ${_NO_DEPS} -eq ${BS_TRUE} ]; then +if [ "${ITYPE}" = "git" ] && [ "${_NO_DEPS}" -eq "${BS_TRUE}" ]; then if ! __git_clone_and_checkout; then echo "Failed to clone and checkout git repository." exit 1 @@ -9619,7 +9823,7 @@ if [ "$_CUSTOM_MASTER_CONFIG" != "null" ] || [ "$_CUSTOM_MINION_CONFIG" != "null _TEMP_CONFIG_DIR="$_SALT_ETC_DIR" fi - if [ ${_NO_DEPS} -eq $BS_FALSE ] && [ $_CONFIG_ONLY -eq $BS_TRUE ]; then + if [ "${_NO_DEPS}" -eq "$BS_FALSE" ] && [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ]; then # Execute function to satisfy dependencies for configuration step echoinfo "Running ${DEPS_INSTALL_FUNC}()" if ! ${DEPS_INSTALL_FUNC}; then @@ -9642,7 +9846,7 @@ fi 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 +master: "$_SALT_MASTER_ADDRESS" _eof fi @@ -9655,78 +9859,78 @@ fi # Pre-seed master keys if [ "$PRESEED_MASTER_FUNC" != "null" ] && [ "$_TEMP_KEYS_DIR" != "null" ]; then echoinfo "Running ${PRESEED_MASTER_FUNC}()" - if ! ${PRESEED_MASTER_FUNC}; then + if ! "${PRESEED_MASTER_FUNC}"; then echoerror "Failed to run ${PRESEED_MASTER_FUNC}()!!!" exit 1 fi 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}()" - if ! ${INSTALL_FUNC}; then + if ! "${INSTALL_FUNC}"; then echoerror "Failed to run ${INSTALL_FUNC}()!!!" exit 1 fi fi # Run any post install function. Only execute function if not in config mode only -if [ "$POST_INSTALL_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then +if [ "$POST_INSTALL_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq "$BS_FALSE" ]; then echoinfo "Running ${POST_INSTALL_FUNC}()" - if ! ${POST_INSTALL_FUNC}; then + if ! "${POST_INSTALL_FUNC}"; then echoerror "Failed to run ${POST_INSTALL_FUNC}()!!!" exit 1 fi fi # Run any check services function, Only execute function if not in config mode only -if [ "$CHECK_SERVICES_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then +if [ "$CHECK_SERVICES_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq "$BS_FALSE" ]; then echoinfo "Running ${CHECK_SERVICES_FUNC}()" - if ! ${CHECK_SERVICES_FUNC}; then + if ! "${CHECK_SERVICES_FUNC}"; then echoerror "Failed to run ${CHECK_SERVICES_FUNC}()!!!" exit 1 fi fi # Run any start daemons function -if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ] && [ ${_START_DAEMONS} -eq $BS_TRUE ]; then +if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ] && [ "${_START_DAEMONS}" -eq "$BS_TRUE" ]; then echoinfo "Running ${STARTDAEMONS_INSTALL_FUNC}()" echodebug "Waiting ${_SLEEP} seconds for processes to settle before checking for them" - sleep ${_SLEEP} - if ! ${STARTDAEMONS_INSTALL_FUNC}; then + sleep "${_SLEEP}" + if ! "${STARTDAEMONS_INSTALL_FUNC}"; then echoerror "Failed to run ${STARTDAEMONS_INSTALL_FUNC}()!!!" exit 1 fi fi # Check if the installed daemons are running or not -if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ ${_START_DAEMONS} -eq $BS_TRUE ]; then +if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ "${_START_DAEMONS}" -eq "$BS_TRUE" ]; then echoinfo "Running ${DAEMONS_RUNNING_FUNC}()" echodebug "Waiting ${_SLEEP} seconds for processes to settle before checking for them" - sleep ${_SLEEP} # Sleep a little bit to let daemons start - if ! ${DAEMONS_RUNNING_FUNC}; then + sleep "${_SLEEP}" # Sleep a little bit to let daemons start + if ! "${DAEMONS_RUNNING_FUNC}"; then echoerror "Failed to run ${DAEMONS_RUNNING_FUNC}()!!!" for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + [ "$fname" = "api" ] && continue # Skip if not meant to be installed - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq "$BS_FALSE" ] && continue + [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -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 - [ ! -f "$_SALT_ETC_DIR/$fname" ] && [ $fname != "syndic" ] && echodebug "$_SALT_ETC_DIR/$fname does not exist" + [ ! -f "$_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)" - [ ! -f /var/log/salt/$fname ] && echodebug "/var/log/salt/$fname does not exist. Can't cat its contents!" && continue + [ ! -f "/var/log/salt/$fname" ] && echodebug "/var/log/salt/$fname does not exist. Can't cat its contents!" && continue echodebug "DAEMON LOGS for $fname:" echodebug "$(cat /var/log/salt/$fname)" @@ -9746,7 +9950,7 @@ if [ "$_AUTO_ACCEPT_MINION_KEYS" -eq "$BS_TRUE" ]; then fi # Done! -if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then +if [ "$_CONFIG_ONLY" -eq "$BS_FALSE" ]; then echoinfo "Salt installed!" else echoinfo "Salt configured!"