Skip to content

Instantly share code, notes, and snippets.

@b01
Last active July 17, 2025 05:04
Show Gist options
  • Save b01/0a16b6645ab7921b0910603dfb85e4fb to your computer and use it in GitHub Desktop.
Save b01/0a16b6645ab7921b0910603dfb85e4fb to your computer and use it in GitHub Desktop.

Revisions

  1. b01 revised this gist Feb 10, 2024. 1 changed file with 33 additions and 38 deletions.
    71 changes: 33 additions & 38 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # Copyright 2023 Khalifah K. Shabazz
    #
    # Permission is hereby granted, free of charge, to any person obtaining a
    # Permission is hereby granted, free of charge, to any person obtaining a
    # copy of this software and associated documentation files (the “Software”),
    # to deal in the Software without restriction, including without limitation
    # the rights to use, copy, modify, merge, publish, distribute, sublicense,
    @@ -22,58 +22,53 @@

    set -e


    # Auto-Get the latest commit sha via command line.
    get_latest_release() {
    tag=$(curl --silent "https://api.github.com/repos/${1}/releases/latest" | # Get latest release from GitHub API
    grep '"tag_name":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    tag_data=$(curl --silent "https://api.github.com/repos/${1}/git/ref/tags/${tag}")

    sha=$(echo "${tag_data}" | # Get latest release from GitHub API
    grep '"sha":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value
    platform=${1}
    arch=${2}

    sha_type=$(echo "${tag_data}" | # Get latest release from GitHub API
    grep '"type":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value
    # Grab the first commit SHA since as this script assumes it will be the
    # latest.
    platform="win32"
    arch="x64"
    commit_id=$(curl --silent "https://update.code.visualstudio.com/api/commits/stable/${platform}-${arch}" | sed s'/^\["\([^"]*\).*$/\1/')

    if [ "${sha_type}" != "commit" ]; then
    combo_sha=$(curl -s "https://api.github.com/repos/${1}/git/tags/${sha}" | # Get latest release from GitHub API
    grep '"sha":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value
    printf "%s" "${commit_id}"
    }

    # Remove the tag sha, leaving only the commit sha;
    # this won't work if there are ever more than 2 sha,
    # and use xargs to remove whitespace/newline.
    sha=$(echo "${combo_sha}" | sed -E "s/${sha}//" | xargs)
    fi
    PLATFORM="${1}"
    ARCH="${2}"

    printf "${sha}"
    }
    if [ -z "${PLATFORM}" ]; then
    echo "please enter a platform, acceptable values are win32, linux, darwin, or alpine"
    exit 1
    fi

    ARCH="x64"
    U_NAME=$(uname -m)
    if [ -z "${ARCH}" ]; then
    U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    elif [ "${U_NAME}" = "armv7l" ]; then
    ARCH="armhf"
    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    elif [ "${U_NAME}" = "armv7l" ]; then
    ARCH="armhf"
    fi
    fi

    archive="vscode-server-linux-${ARCH}.tar.gz"
    owner='microsoft'
    repo='vscode'
    commit_sha=$(get_latest_release "${owner}/${repo}")
    commit_sha=$(get_latest_release "${PLATFORM}" "${ARCH}")

    if [ -n "${commit_sha}" ]; then
    echo "will attempt to download VS Code Server version = '${commit_sha}'"

    prefix="server-${PLATFORM}"
    if [ "${PLATFORM}" = "alpine" ]; then
    prefix="cli-${PLATFORM}"
    fi

    archive="vscode-${prefix}-${ARCH}.tar.gz"
    # Download VS Code Server tarball to tmp directory.
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-${ARCH}/stable" -o "/tmp/${archive}"
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/${prefix}-${ARCH}/stable" -o "/tmp/${archive}"

    # Make the parent directory where the server should live.
    # NOTE: Ensure VS Code will have read/write access; namely the user running VScode or container user.
  2. b01 revised this gist Nov 17, 2023. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,28 @@
    #!/bin/sh

    # Copyright 2023 Khalifah K. Shabazz
    #
    # Permission is hereby granted, free of charge, to any person obtaining a
    # copy of this software and associated documentation files (the “Software”),
    # to deal in the Software without restriction, including without limitation
    # the rights to use, copy, modify, merge, publish, distribute, sublicense,
    # and/or sell copies of the Software, and to permit persons to whom the
    # Software is furnished to do so, subject to the following conditions:

    # The above copyright notice and this permission notice shall be included in
    # all copies or substantial portions of the Software.

    # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    # IN THE SOFTWARE.

    set -e


    # Auto-Get the latest commit sha via command line.
    get_latest_release() {
    tag=$(curl --silent "https://api.github.com/repos/${1}/releases/latest" | # Get latest release from GitHub API
  3. b01 revised this gist Aug 27, 2023. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,10 @@ U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    elif [ "${U_NAME}" = "armv7l" ]; then
    ARCH="armhf"
    fi

    archive="vscode-server-linux-${ARCH}.tar.gz"
    @@ -56,6 +60,8 @@ if [ -n "${commit_sha}" ]; then

    # Extract the tarball to the right location.
    tar --no-same-owner -xzv --strip-components=1 -C ~/.vscode-server/bin/"${commit_sha}" -f "/tmp/${archive}"
    # Add symlink
    cd ~/.vscode-server/bin && ln -s "${commit_sha}" default_version
    else
    echo "could not pre install vscode server"
    fi
    fi
  4. b01 revised this gist Jun 9, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ if [ -n "${commit_sha}" ]; then
    echo "will attempt to download VS Code Server version = '${commit_sha}'"

    # Download VS Code Server tarball to tmp directory.
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-x64/stable" -o "/tmp/${archive}"
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-${ARCH}/stable" -o "/tmp/${archive}"

    # Make the parent directory where the server should live.
    # NOTE: Ensure VS Code will have read/write access; namely the user running VScode or container user.
  5. b01 revised this gist Jun 7, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -32,12 +32,11 @@ get_latest_release() {
    printf "${sha}"
    }

    ARCH="x64"
    U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    fi

    archive="vscode-server-linux-${ARCH}.tar.gz"
  6. b01 revised this gist Jun 7, 2022. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -45,14 +45,18 @@ owner='microsoft'
    repo='vscode'
    commit_sha=$(get_latest_release "${owner}/${repo}")

    echo "will attempt to download VS Code Server version = '${commit_sha}'"
    if [ -n "${commit_sha}" ]; then
    echo "will attempt to download VS Code Server version = '${commit_sha}'"

    # Download VS Code Server tarball to tmp directory.
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-x64/stable" -o "/tmp/${archive}"
    # Download VS Code Server tarball to tmp directory.
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-x64/stable" -o "/tmp/${archive}"

    # Make the parent directory where the server should live.
    # NOTE: Ensure VS Code will have read/write access; namely the user running VScode or container user.
    mkdir -vp ~/.vscode-server/bin/"${commit_sha}"
    # Make the parent directory where the server should live.
    # NOTE: Ensure VS Code will have read/write access; namely the user running VScode or container user.
    mkdir -vp ~/.vscode-server/bin/"${commit_sha}"

    # Extract the tarball to the right location.
    tar --no-same-owner -xzv --strip-components=1 -C ~/.vscode-server/bin/"${commit_sha}" -f "/tmp/${archive}"
    # Extract the tarball to the right location.
    tar --no-same-owner -xzv --strip-components=1 -C ~/.vscode-server/bin/"${commit_sha}" -f "/tmp/${archive}"
    else
    echo "could not pre install vscode server"
    fi
  7. b01 revised this gist Jun 7, 2022. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -40,8 +40,6 @@ elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    fi

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
    commit_sha="08a217c4d27a02a5bcde898fd7981bda5b49391b"
    archive="vscode-server-linux-${ARCH}.tar.gz"
    owner='microsoft'
    repo='vscode'
  8. b01 revised this gist Jun 7, 2022. 1 changed file with 13 additions and 14 deletions.
    27 changes: 13 additions & 14 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -2,20 +2,6 @@

    set -e

    U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    fi

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
    commit_sha="08a217c4d27a02a5bcde898fd7981bda5b49391b"
    archive="vscode-server-linux-${ARCH}.tar.gz"
    owner='microsoft'
    repo='vscode'

    # Auto-Get the latest commit sha via command line.
    get_latest_release() {
    tag=$(curl --silent "https://api.github.com/repos/${1}/releases/latest" | # Get latest release from GitHub API
    @@ -46,6 +32,19 @@ get_latest_release() {
    printf "${sha}"
    }

    U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    fi

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
    commit_sha="08a217c4d27a02a5bcde898fd7981bda5b49391b"
    archive="vscode-server-linux-${ARCH}.tar.gz"
    owner='microsoft'
    repo='vscode'
    commit_sha=$(get_latest_release "${owner}/${repo}")

    echo "will attempt to download VS Code Server version = '${commit_sha}'"
  9. b01 revised this gist Jun 7, 2022. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,12 @@

    set -e

    ARCH="x64"
    if [ "${ARCH}" = "aarch64" ]; then
    U_NAME=$(uname -m)

    if [ "${U_NAME}" = "aarch64" ]; then
    ARCH="arm64"
    elif [ "${U_NAME}" = "x86_64" ]; then
    ARCH="x64"
    fi

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
  10. b01 revised this gist Jun 7, 2022. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,15 @@
    #!/bin/sh

    set -e

    ARCH="x64"
    if [ "${ARCH}" = "aarch64" ]; then
    ARCH="arm64"
    fi

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
    commit_sha="08a217c4d27a02a5bcde898fd7981bda5b49391b"
    archive="vscode-server-linux-x64.tar.gz"
    archive="vscode-server-linux-${ARCH}.tar.gz"
    owner='microsoft'
    repo='vscode'

    @@ -23,7 +29,7 @@ get_latest_release() {
    grep '"type":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    if [[ "${sha_type}" != "commit" ]]; then
    if [ "${sha_type}" != "commit" ]; then
    combo_sha=$(curl -s "https://api.github.com/repos/${1}/git/tags/${sha}" | # Get latest release from GitHub API
    grep '"sha":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value
  11. b01 created this gist Apr 17, 2021.
    52 changes: 52 additions & 0 deletions download-vs-code-server.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    #!/bin/sh
    set -e

    # You can get the latest commit SHA by looking at the latest tagged commit here: https://github.com/microsoft/vscode/releases
    commit_sha="08a217c4d27a02a5bcde898fd7981bda5b49391b"
    archive="vscode-server-linux-x64.tar.gz"
    owner='microsoft'
    repo='vscode'

    # Auto-Get the latest commit sha via command line.
    get_latest_release() {
    tag=$(curl --silent "https://api.github.com/repos/${1}/releases/latest" | # Get latest release from GitHub API
    grep '"tag_name":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    tag_data=$(curl --silent "https://api.github.com/repos/${1}/git/ref/tags/${tag}")

    sha=$(echo "${tag_data}" | # Get latest release from GitHub API
    grep '"sha":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    sha_type=$(echo "${tag_data}" | # Get latest release from GitHub API
    grep '"type":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    if [[ "${sha_type}" != "commit" ]]; then
    combo_sha=$(curl -s "https://api.github.com/repos/${1}/git/tags/${sha}" | # Get latest release from GitHub API
    grep '"sha":' | # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/' ) # Pluck JSON value

    # Remove the tag sha, leaving only the commit sha;
    # this won't work if there are ever more than 2 sha,
    # and use xargs to remove whitespace/newline.
    sha=$(echo "${combo_sha}" | sed -E "s/${sha}//" | xargs)
    fi

    printf "${sha}"
    }

    commit_sha=$(get_latest_release "${owner}/${repo}")

    echo "will attempt to download VS Code Server version = '${commit_sha}'"

    # Download VS Code Server tarball to tmp directory.
    curl -L "https://update.code.visualstudio.com/commit:${commit_sha}/server-linux-x64/stable" -o "/tmp/${archive}"

    # Make the parent directory where the server should live.
    # NOTE: Ensure VS Code will have read/write access; namely the user running VScode or container user.
    mkdir -vp ~/.vscode-server/bin/"${commit_sha}"

    # Extract the tarball to the right location.
    tar --no-same-owner -xzv --strip-components=1 -C ~/.vscode-server/bin/"${commit_sha}" -f "/tmp/${archive}"