|
1 |
| -#!/usr/bin/env sh |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | BOLD='\033[0;1m'
|
| 4 | +EXTENSIONS=("${EXTENSIONS}") |
4 | 5 |
|
5 |
| -# Create install directory if it doesn't exist |
6 |
| -mkdir -p ${INSTALL_DIR} |
| 6 | +# Create install prefix |
| 7 | +mkdir -p ${INSTALL_PREFIX} |
7 | 8 |
|
8 |
| -printf "$${BOLD}Installing vscode-cli!\n" |
| 9 | +printf "$${BOLD}Installing Microsoft Visual Studio Code Server!\n" |
9 | 10 |
|
10 |
| -# Download and extract code-cli tarball |
11 |
| -output=$(curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz && tar -xf vscode_cli.tar.gz -C ${INSTALL_DIR} && rm vscode_cli.tar.gz) |
| 11 | +# Download and extract vscode-server |
| 12 | +ARCH=$(uname -m) |
| 13 | +case "$ARCH" in |
| 14 | + x86_64) ARCH="x64" ;; |
| 15 | + aarch64) ARCH="arm64" ;; |
| 16 | + *) |
| 17 | + echo "Unsupported architecture" |
| 18 | + exit 1 |
| 19 | + ;; |
| 20 | +esac |
| 21 | + |
| 22 | +HASH=$(curl https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH-web | cut -d '"' -f 2) |
| 23 | +output=$(curl -sL https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH/vscode-server-linux-$ARCH-web.tar.gz | tar -xz -C ${INSTALL_PREFIX} --strip-components 1) |
12 | 24 |
|
13 | 25 | if [ $? -ne 0 ]; then
|
14 |
| - echo "Failed to install vscode-cli: $output" |
| 26 | + echo "Failed to install Microsoft Visual Studio Code Server: $output" |
15 | 27 | exit 1
|
16 | 28 | fi
|
17 |
| -printf "🥳 vscode-cli has been installed.\n\n" |
| 29 | +printf "$${BOLD}Microsoft Visual Studio Code Server has been installed.\n" |
| 30 | + |
| 31 | +VSCODE_SERVER="${INSTALL_PREFIX}/bin/code-server" |
| 32 | + |
| 33 | +# Install each extension... |
| 34 | +IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}" |
| 35 | +for extension in "$${EXTENSIONLIST[@]}"; do |
| 36 | + if [ -z "$extension" ]; then |
| 37 | + continue |
| 38 | + fi |
| 39 | + printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n" |
| 40 | + output=$($VSCODE_SERVER --install-extension "$extension" --force) |
| 41 | + if [ $? -ne 0 ]; then |
| 42 | + echo "Failed to install extension: $extension: $output" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +done |
18 | 46 |
|
19 |
| -echo "👷 Running ${INSTALL_DIR}/bin/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms in the background..." |
| 47 | +echo "👷 Running ${INSTALL_PREFIX}/bin/code-server serve-local --port ${PORT} --accept-server-license-terms serve-local --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..." |
20 | 48 | echo "Check logs at ${LOG_PATH}!"
|
21 |
| -${INSTALL_DIR}/code serve-web --port ${PORT} --without-connection-token --accept-server-license-terms > ${LOG_PATH} 2>&1 & |
| 49 | +"${INSTALL_PREFIX}/bin/code-server" serve-local --port "${PORT}" --accept-server-license-terms serve-local --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 & |
0 commit comments