diff --git a/src/serverSetup.ts b/src/serverSetup.ts index 31ae65f..2a401c7 100644 --- a/src/serverSetup.ts +++ b/src/serverSetup.ts @@ -322,6 +322,7 @@ SERVER_DOWNLOAD_URL="$(echo "${serverDownloadUrlTemplate.replace(/\$\{/g, '\\${' # Check if server script is already installed if [[ ! -f $SERVER_SCRIPT ]]; then + extract_dir="$(mktemp -d)" case "$PLATFORM" in darwin | linux | alpine ) ;; @@ -334,9 +335,9 @@ if [[ ! -f $SERVER_SCRIPT ]]; then pushd $SERVER_DIR > /dev/null if [[ ! -z $(which wget) ]]; then - wget --tries=3 --timeout=10 --continue --no-verbose -O vscode-server.tar.gz $SERVER_DOWNLOAD_URL + wget --tries=3 --timeout=10 --continue --no-verbose -O "$extract_dir/vscode-server.tar.gz" $SERVER_DOWNLOAD_URL elif [[ ! -z $(which curl) ]]; then - curl --retry 3 --connect-timeout 10 --location --show-error --silent --output vscode-server.tar.gz $SERVER_DOWNLOAD_URL + curl --retry 3 --connect-timeout 10 --location --show-error --silent --output "$extract_dir/vscode-server.tar.gz" $SERVER_DOWNLOAD_URL else echo "Error no tool to download server binary" print_install_results_and_exit 1 @@ -347,7 +348,7 @@ if [[ ! -f $SERVER_SCRIPT ]]; then print_install_results_and_exit 1 fi - tar -xf vscode-server.tar.gz --strip-components 1 + tar -xf "$extract_dir/vscode-server.tar.gz" --strip-components 1 if (( $? > 0 )); then echo "Error while extracting server contents" print_install_results_and_exit 1 @@ -358,7 +359,11 @@ if [[ ! -f $SERVER_SCRIPT ]]; then print_install_results_and_exit 1 fi - rm -f vscode-server.tar.gz + rm -f "$extract_dir/vscode-server.tar.gz" + + cp -r "$extract_dir/*" . + + rm -rf "$extract_dir" popd > /dev/null else