summaryrefslogtreecommitdiffstats
path: root/packaging/installer
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2022-06-03 07:32:50 -0400
committerGitHub <noreply@github.com>2022-06-03 07:32:50 -0400
commit9f7ddf5fd6fd400a12a7822b31e45bac207c4f03 (patch)
tree1dbc59ae0146e313336dcab64b5250a72929a06a /packaging/installer
parent1ebba582cfdbc94a8a2ae1702941b3070bafe6cf (diff)
Fix handling of temp directory in kickstart when uninstalling. (#13056)
This makes temporary directory creation idempotent, and ensures it’s invoked in each place that needs it. It also tidies up the cleanup code so that it only tries to remove the temporary directory if one was created.
Diffstat (limited to 'packaging/installer')
-rwxr-xr-xpackaging/installer/kickstart.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index 2eaff71757..a1079c3fd7 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -101,9 +101,7 @@ main() {
;;
esac
- tmpdir="$(create_tmp_directory)"
- progress "Using ${tmpdir} as a temporary directory."
- cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
+ set_tmpdir
if [ -n "${INSTALL_VERSION}" ]; then
if echo "${INSTALL_VERSION}" | grep -E -o "^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$" > /dev/null 2>&1; then
@@ -373,7 +371,8 @@ success_banner() {
}
cleanup() {
- if [ -z "${NO_CLEANUP}" ]; then
+ if [ -z "${NO_CLEANUP}" ] && [ -n "${tmpdir}" ]; then
+ cd || true
${ROOTCMD} rm -rf "${tmpdir}"
fi
}
@@ -506,6 +505,14 @@ create_tmp_directory() {
mktemp -d -t netdata-kickstart-XXXXXXXXXX
}
+set_tmpdir() {
+ if [ -z "${tmpdir}" ]; then
+ tmpdir="$(create_tmp_directory)"
+ progress "Using ${tmpdir} as a temporary directory."
+ cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
+ fi
+}
+
check_for_remote_file() {
url="${1}"
@@ -710,6 +717,7 @@ update() {
}
uninstall() {
+ set_tmpdir
get_system_info
detect_existing_install