diff --git a/install.sh b/install.sh index cdb0bed420..50c3c85a8f 100755 --- a/install.sh +++ b/install.sh @@ -639,19 +639,21 @@ install_standalone() { # fails we can ignore the error as the -w check will then swap us to sudo. sh_c mkdir -p "$STANDALONE_INSTALL_PREFIX" 2>/dev/null || true + sh_c mkdir -p "$CACHE_DIR/tmp" + if [ "$STANDALONE_ARCHIVE_FORMAT" = tar.gz ]; then + sh_c tar -C "$CACHE_DIR/tmp" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar.gz" + else + sh_c unzip -d "$CACHE_DIR/tmp" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip" + fi + + STANDALONE_BINARY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME" + sh_c="sh_c" if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then sh_c="sudo_sh_c" fi "$sh_c" mkdir -p "$STANDALONE_INSTALL_PREFIX/bin" - if [ "$STANDALONE_ARCHIVE_FORMAT" = tar.gz ]; then - "$sh_c" tar -C "$CACHE_DIR" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar.gz" - else - "$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip" - fi - - STANDALONE_BINARY_LOCATION="$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME" # Remove the file if it already exists to # avoid https://github.com/coder/coder/issues/2086 @@ -660,7 +662,10 @@ install_standalone() { fi # Copy the binary to the correct location. - "$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_BINARY_LOCATION" + "$sh_c" cp "$CACHE_DIR/tmp/coder" "$STANDALONE_BINARY_LOCATION" + + # Clean up the extracted files (note, not using sudo: $sh_c -> sh_c). + sh_c rm -rv "$CACHE_DIR/tmp" echo_standalone_postinstall }