Skip to content

Commit b06452e

Browse files
authored
fix(install.sh): remove extracted files after installation (#12879)
1 parent 7c0fac9 commit b06452e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

install.sh

+13-8
Original file line numberDiff line numberDiff line change
@@ -639,19 +639,21 @@ install_standalone() {
639639
# fails we can ignore the error as the -w check will then swap us to sudo.
640640
sh_c mkdir -p "$STANDALONE_INSTALL_PREFIX" 2>/dev/null || true
641641

642+
sh_c mkdir -p "$CACHE_DIR/tmp"
643+
if [ "$STANDALONE_ARCHIVE_FORMAT" = tar.gz ]; then
644+
sh_c tar -C "$CACHE_DIR/tmp" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar.gz"
645+
else
646+
sh_c unzip -d "$CACHE_DIR/tmp" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip"
647+
fi
648+
649+
STANDALONE_BINARY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME"
650+
642651
sh_c="sh_c"
643652
if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then
644653
sh_c="sudo_sh_c"
645654
fi
646655

647656
"$sh_c" mkdir -p "$STANDALONE_INSTALL_PREFIX/bin"
648-
if [ "$STANDALONE_ARCHIVE_FORMAT" = tar.gz ]; then
649-
"$sh_c" tar -C "$CACHE_DIR" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar.gz"
650-
else
651-
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip"
652-
fi
653-
654-
STANDALONE_BINARY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME"
655657

656658
# Remove the file if it already exists to
657659
# avoid https://github.com/coder/coder/issues/2086
@@ -660,7 +662,10 @@ install_standalone() {
660662
fi
661663

662664
# Copy the binary to the correct location.
663-
"$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_BINARY_LOCATION"
665+
"$sh_c" cp "$CACHE_DIR/tmp/coder" "$STANDALONE_BINARY_LOCATION"
666+
667+
# Clean up the extracted files (note, not using sudo: $sh_c -> sh_c).
668+
sh_c rm -rv "$CACHE_DIR/tmp"
664669

665670
echo_standalone_postinstall
666671
}

0 commit comments

Comments
 (0)