diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2023-02-16 07:31:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 07:31:06 -0500 |
commit | 5c7bd2c6488cd19fa4a0eb435221223ea5e7de81 (patch) | |
tree | 68ca846d6778b3f161a4fad6d44c411d649820b3 /packaging | |
parent | fe5f3b64927e9efb26bdf6d6401e6cd078b738ea (diff) |
Assorted shellcheck cleanup. (#14524)
* Add shellcheck config file to globally disable dead code checks.
These checks have an extremely high false positive rate and even when
they’re correctly flagging code the impact is generally very low.
* Fix assorted shellcheck errors in installer code.
This should make reviewing PRs relating to this code much easier.
* Make shellcheck quit complaining about shellcheckrc formatting.
Diffstat (limited to 'packaging')
-rwxr-xr-x | packaging/installer/dependencies/centos.sh | 2 | ||||
-rw-r--r-- | packaging/installer/functions.sh | 4 | ||||
-rwxr-xr-x | packaging/installer/install-required-packages.sh | 12 | ||||
-rwxr-xr-x | packaging/installer/netdata-uninstaller.sh | 12 | ||||
-rwxr-xr-x | packaging/makeself/install-or-update.sh | 2 |
5 files changed, 27 insertions, 5 deletions
diff --git a/packaging/installer/dependencies/centos.sh b/packaging/installer/dependencies/centos.sh index a05bce8f01..1e44a9ffa4 100755 --- a/packaging/installer/dependencies/centos.sh +++ b/packaging/installer/dependencies/centos.sh @@ -96,7 +96,7 @@ check_flags() { validate_tree_centos() { local opts= - export local package_manager= + package_manager= if [[ "${NON_INTERACTIVE}" == "1" ]]; then echo >&2 "Running in non-interactive mode" opts="-y" diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh index 3efaca528d..1f121da4de 100644 --- a/packaging/installer/functions.sh +++ b/packaging/installer/functions.sh @@ -411,7 +411,7 @@ get_group(){ if command -v getent > /dev/null 2>&1; then getent group "${1:-""}" else - cat /etc/group | grep "^${1}:" + grep "^${1}:" /etc/group fi } @@ -600,7 +600,7 @@ install_netdata_service() { echo >&2 "Note: To explicitly enable netdata automatic start, set 'netdata_enable' to 'YES' in /etc/rc.conf" echo >&2 "" - return ${myret} + return "${myret}" elif issystemd; then # systemd is running on this system diff --git a/packaging/installer/install-required-packages.sh b/packaging/installer/install-required-packages.sh index c906cce34f..a4b93028b8 100755 --- a/packaging/installer/install-required-packages.sh +++ b/packaging/installer/install-required-packages.sh @@ -1376,6 +1376,7 @@ validate_tree_freebsd() { echo >&2 " > Checking for gmake ..." if ! pkg query %n-%v | grep -q gmake; then if prompt "gmake is required to build on FreeBSD and is not installed. Shall I install it?"; then + # shellcheck disable=2086 run ${sudo} pkg install ${opts} gmake fi fi @@ -1425,13 +1426,16 @@ validate_tree_centos() { echo >&2 " > Checking for config-manager ..." if ! run ${sudo} dnf config-manager --help; then if prompt "config-manager not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} dnf ${opts} install 'dnf-command(config-manager)' fi fi echo >&2 " > Checking for CRB ..." + # shellcheck disable=2086 if ! run dnf ${sudo} repolist | grep CRB; then if prompt "CRB not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} dnf ${opts} config-manager --set-enabled crb fi fi @@ -1439,24 +1443,29 @@ validate_tree_centos() { echo >&2 " > Checking for config-manager ..." if ! run ${sudo} yum config-manager --help; then if prompt "config-manager not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} yum ${opts} install 'dnf-command(config-manager)' fi fi echo >&2 " > Checking for PowerTools ..." + # shellcheck disable=2086 if ! run yum ${sudo} repolist | grep PowerTools; then if prompt "PowerTools not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} yum ${opts} config-manager --set-enabled powertools fi fi echo >&2 " > Updating libarchive ..." + # shellcheck disable=2086 run ${sudo} yum ${opts} install libarchive elif [[ "${version}" =~ ^7(\..*)?$ ]]; then echo >&2 " > Checking for EPEL ..." if ! rpm -qa | grep epel-release > /dev/null; then if prompt "EPEL not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} yum ${opts} install epel-release fi fi @@ -1465,6 +1474,7 @@ validate_tree_centos() { echo >&2 " > Checking for Okay ..." if ! rpm -qa | grep okay > /dev/null; then if prompt "okay not found, shall I install it?"; then + # shellcheck disable=2086 run ${sudo} yum ${opts} install http://repo.okay.com.mx/centos/6/x86_64/release/okay-release-1-3.el6.noarch.rpm fi fi @@ -1627,7 +1637,7 @@ install_equo() { PACMAN_DB_SYNCED=0 validate_install_pacman() { - if [ ${PACMAN_DB_SYNCED} -eq 0 ]; then + if [ "${PACMAN_DB_SYNCED}" -eq 0 ]; then echo >&2 " > Running pacman -Sy to sync the database" local x x=$(pacman -Sy) diff --git a/packaging/installer/netdata-uninstaller.sh b/packaging/installer/netdata-uninstaller.sh index 2f2e89ffdc..419002e6a6 100755 --- a/packaging/installer/netdata-uninstaller.sh +++ b/packaging/installer/netdata-uninstaller.sh @@ -239,15 +239,18 @@ if [ -x "$(command -v apt-get)" ] && [ "${INSTALL_TYPE}" = "binpkg-deb" ]; then if dpkg -s netdata > /dev/null; then echo "Found netdata native installation" if user_input "Do you want to remove netdata? "; then + # shellcheck disable=SC2086 apt-get remove netdata ${FLAG} fi if dpkg -s netdata-repo-edge > /dev/null; then if user_input "Do you want to remove netdata-repo-edge? "; then + # shellcheck disable=SC2086 apt-get remove netdata-repo-edge ${FLAG} fi fi if dpkg -s netdata-repo > /dev/null; then if user_input "Do you want to remove netdata-repo? "; then + # shellcheck disable=SC2086 apt-get remove netdata-repo ${FLAG} fi fi @@ -257,15 +260,18 @@ elif [ -x "$(command -v dnf)" ] && [ "${INSTALL_TYPE}" = "binpkg-rpm" ]; then if rpm -q netdata > /dev/null; then echo "Found netdata native installation." if user_input "Do you want to remove netdata? "; then + # shellcheck disable=SC2086 dnf remove netdata ${FLAG} fi if rpm -q netdata-repo-edge > /dev/null; then if user_input "Do you want to remove netdata-repo-edge? "; then + # shellcheck disable=SC2086 dnf remove netdata-repo-edge ${FLAG} fi fi if rpm -q netdata-repo > /dev/null; then if user_input "Do you want to remove netdata-repo? "; then + # shellcheck disable=SC2086 dnf remove netdata-repo ${FLAG} fi fi @@ -275,15 +281,18 @@ elif [ -x "$(command -v yum)" ] && [ "${INSTALL_TYPE}" = "binpkg-rpm" ]; then if rpm -q netdata > /dev/null; then echo "Found netdata native installation." if user_input "Do you want to remove netdata? "; then + # shellcheck disable=SC2086 yum remove netdata ${FLAG} fi if rpm -q netdata-repo-edge > /dev/null; then if user_input "Do you want to remove netdata-repo-edge? "; then + # shellcheck disable=SC2086 yum remove netdata-repo-edge ${FLAG} fi fi if rpm -q netdata-repo > /dev/null; then if user_input "Do you want to remove netdata-repo? "; then + # shellcheck disable=SC2086 yum remove netdata-repo ${FLAG} fi fi @@ -296,15 +305,18 @@ elif [ -x "$(command -v zypper)" ] && [ "${INSTALL_TYPE}" = "binpkg-rpm" ]; then if zypper search -i netdata > /dev/null; then echo "Found netdata native installation." if user_input "Do you want to remove netdata? "; then + # shellcheck disable=SC2086 zypper ${FLAG} remove netdata fi if zypper search -i netdata-repo-edge > /dev/null; then if user_input "Do you want to remove netdata-repo-edge? "; then + # shellcheck disable=SC2086 zypper ${FLAG} remove netdata-repo-edge fi fi if zypper search -i netdata-repo > /dev/null; then if user_input "Do you want to remove netdata-repo? "; then + # shellcheck disable=SC2086 zypper ${FLAG} remove netdata-repo fi fi diff --git a/packaging/makeself/install-or-update.sh b/packaging/makeself/install-or-update.sh index 52a23fc706..62089f4e98 100755 --- a/packaging/makeself/install-or-update.sh +++ b/packaging/makeself/install-or-update.sh @@ -179,7 +179,7 @@ dir_should_be_link() { fi run ln -s "${t}" "${d}" - cd "${old}" + cd "${old}" || true } dir_should_be_link . bin sbin |