Skip to content

Commit

Permalink
Fix shellcheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WStechura committed Jan 3, 2025
1 parent 39fec6a commit 6d8d5fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/sh
#!/bin/bash -eu

# This script acts as a self contained installer of the procuct

set -e

readonly DEFAULT_INSTALL_DIR="/opt/dynatrace/oneagent"
readonly INSTALLER_VERSION="##VERSION##"
readonly DEPLOYMENT_CONF_PATH="/var/lib/dynatrace/oneagent/agent/config"

readonly UNINSTALL_SCRIPT="uninstall.sh"
# shellcheck disable=SC2155
readonly UNINSTALL_CODE="$(cat <<-ENDUNINSTALL
##UNINSTALL_CODE##
ENDUNINSTALL
)"

readonly ONEAGENTCTL_BIN="oneagentctl"
# shellcheck disable=SC2155
readonly ONEAGENTCTL_CODE="$(cat <<-ENDCTL
##ONEAGENTCTL_CODE##
ENDCTL
Expand Down Expand Up @@ -61,6 +61,7 @@ deployUninstallScript() {
}

applyConfig() {
# shellcheck disable=SC2086
"${INSTALL_DIR}/agent/tools/${ONEAGENTCTL_BIN}" ${CTL_PARAMS}
}

Expand Down
9 changes: 4 additions & 5 deletions roles/oneagent/tests/resources/installers/oneagentctl.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/bash
#!/bin/bash -eu

# This file simulates deployment functionalities of oneagentctl binary, used to configure installation.

set -e

readonly INSTALLER_VERSION="##VERSION##"
readonly DEPLOYMENT_CONF_PATH="/var/lib/dynatrace/oneagent/agent/config"

Expand All @@ -14,6 +11,7 @@ cutVariable() {
printf "%s" "${variable}" | cut -d "${delimiter}" -f "${fields}"
}

# shellcheck disable=SC2155
saveToConfig() {
while [ $# -gt 0 ]; do
# example command: --set-host-property=TENANT=tenant1
Expand All @@ -36,6 +34,7 @@ saveToConfig() {
}

readFromConfig() {
# shellcheck disable=SC2155
local getterType="$(cutVariable "${1}" "-" "5-")"

if [ "${getterType}" = "properties" ]; then
Expand All @@ -49,7 +48,7 @@ main() {
if [ "${1}" = '--version' ]; then
printf '%s\n' "${INSTALLER_VERSION}"
elif printf "%s" "${1}" | grep -q "^--get"; then
readFromConfig ${1}
readFromConfig "${1}"
elif printf "%s" "${1}" | grep -q "^--set"; then
saveToConfig "$@"
fi
Expand Down

0 comments on commit 6d8d5fb

Please sign in to comment.